FORGE-85: parse D1's extended constraint messages; dialect-aware D1 tests #745

Merged
gmackie merged 1 commit from FORGE-85-d1-lane-fixes into main 2026-10-12 07:47:30 +00:00
Owner

Follow-up to FORGE-85 (#703, #706, #708, #712) for the non-required database-d1 lane.

  • Real gap fixed: local D1 reports UNIQUE constraint failed: changesets.id: SQLITE_CONSTRAINT (extended: SQLITE_CONSTRAINT_PRIMARYKEY). classifyDbError kept the suffix in the column name, so column-based checks (deployment_events.seq collisions in #713) could never match on D1. The column list now stops at : SQLITE_. A unit test covers the exact D1 message.
  • db-error-classification: asserts the SQLite shape on D1 and runs the FK case there too (D1 enforces FKs).
  • registry-stale-cutoff: the bound cutoff is tested through drizzle on both dialects; the raw-SQL encoder bind (registry raw Postgres until Phase 6) is Postgres-only.
  • json-helpers: jsonGet and counts run on D1; jsonMerge stays Postgres until the D1 schema swaps its body (per-key json_set); ::int reference values are Postgres-only.
  • d1-known-failures.txt: + deployment-events-seq-index (its serial-default first try has no default on D1; #713 removes that path).

Verification: pnpm --filter @forgegraph/api test:d1 27 files passed, 0 failed. The changed files pass on D1, PGlite and Postgres 16. packages/db errors tests 9/9. No schema change.

🤖 Generated with Claude Code

Follow-up to FORGE-85 (#703, #706, #708, #712) for the non-required `database-d1` lane. - **Real gap fixed:** local D1 reports `UNIQUE constraint failed: changesets.id: SQLITE_CONSTRAINT (extended: SQLITE_CONSTRAINT_PRIMARYKEY)`. `classifyDbError` kept the suffix in the column name, so column-based checks (deployment_events.seq collisions in #713) could never match on D1. The column list now stops at `: SQLITE_`. A unit test covers the exact D1 message. - `db-error-classification`: asserts the SQLite shape on D1 and runs the FK case there too (D1 enforces FKs). - `registry-stale-cutoff`: the bound cutoff is tested through drizzle on both dialects; the raw-SQL encoder bind (registry raw Postgres until Phase 6) is Postgres-only. - `json-helpers`: `jsonGet` and counts run on D1; `jsonMerge` stays Postgres until the D1 schema swaps its body (per-key json_set); `::int` reference values are Postgres-only. - `d1-known-failures.txt`: + `deployment-events-seq-index` (its serial-default first try has no default on D1; #713 removes that path). Verification: `pnpm --filter @forgegraph/api test:d1` 27 files passed, 0 failed. The changed files pass on D1, PGlite and Postgres 16. packages/db errors tests 9/9. No schema change. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
FORGE-85: parse D1's extended constraint messages; dialect-aware D1 tests
Some checks failed
CI / superseded (pull_request) Successful in 0s
CI / gitleaks (pull_request) Successful in 14s
CI / go (pull_request) Successful in 59s
CI / storybook (pull_request) Successful in 1m59s
CI / unit-web (pull_request) Failing after 1m33s
CI / checks (pull_request) Successful in 3m48s
CI / web-build (pull_request) Successful in 3m57s
CI / database (pull_request) Successful in 4m18s
CI / unit-api (pull_request) Successful in 3m29s
CI / database-d1 (pull_request) Successful in 6m45s
forgegraph/ci CI failed
CI / ci (pull_request) Failing after 31s
7669d57a26
Local D1 reports a primary-key or unique violation as
"UNIQUE constraint failed: t.c: SQLITE_CONSTRAINT (extended:
SQLITE_CONSTRAINT_PRIMARYKEY)". classifyDbError kept the suffix in the
column name, so a column-based check (deployment_events.seq collisions in
#713) would never match on D1. Stop the column list at ': SQLITE_'.

The D1 lane (database-d1) failed db-error-classification and
registry-stale-cutoff because the tests asserted Postgres shapes:
- db-error-classification asserts the SQLite shape on D1 and runs the
  foreign-key case there too (D1 enforces FKs).
- registry-stale-cutoff tests the bound cutoff through drizzle on both
  dialects; the raw-SQL encoder bind (registry raw Postgres until Phase 6)
  is Postgres-only.
- json-helpers: jsonGet and the counts run on D1; jsonMerge stays Postgres
  until the D1 schema swaps its body; the ::int reference values are
  Postgres-only.
- d1-known-failures: deployment-events-seq-index (its serial-default first
  try has no default on D1; #713 removes it).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Author
Owner

Preview environment is live: https://pr-745-forgegraph.forgegraf.com

Deployed 7669d57a with the beta stage's environment. It redeploys on every push and is destroyed when this PR closes.

Preview environment is live: https://pr-745-forgegraph.forgegraf.com Deployed `7669d57a` with the beta stage's environment. It redeploys on every push and is destroyed when this PR closes.
gmackie force-pushed FORGE-85-d1-lane-fixes from 7669d57a26
Some checks failed
CI / superseded (pull_request) Successful in 0s
CI / gitleaks (pull_request) Successful in 14s
CI / go (pull_request) Successful in 59s
CI / storybook (pull_request) Successful in 1m59s
CI / unit-web (pull_request) Failing after 1m33s
CI / checks (pull_request) Successful in 3m48s
CI / web-build (pull_request) Successful in 3m57s
CI / database (pull_request) Successful in 4m18s
CI / unit-api (pull_request) Successful in 3m29s
CI / database-d1 (pull_request) Successful in 6m45s
forgegraph/ci CI failed
CI / ci (pull_request) Failing after 31s
to 1b1bb220c7
All checks were successful
CI / superseded (pull_request) Successful in 1s
CI / gitleaks (pull_request) Successful in 13s
CI / go (pull_request) Successful in 1m9s
CI / storybook (pull_request) Successful in 2m24s
CI / checks (pull_request) Successful in 2m36s
CI / web-build (pull_request) Successful in 2m53s
CI / unit-api (pull_request) Successful in 2m4s
CI / database (pull_request) Successful in 3m31s
CI / unit-web (pull_request) Successful in 2m47s
forgegraph/ci CI passed
CI / ci (pull_request) Successful in 47s
CI / database-d1 (pull_request) Successful in 9m25s
2026-10-12 07:35:48 +00:00
Compare
Author
Owner

Preview environment is live: https://pr-745-forgegraph.forgegraf.com

Deployed 1b1bb220 with the beta stage's environment. It redeploys on every push and is destroyed when this PR closes.

Preview environment is live: https://pr-745-forgegraph.forgegraf.com Deployed `1b1bb220` with the beta stage's environment. It redeploys on every push and is destroyed when this PR closes.
Author
Owner

Preview environment is live: https://pr-745-forgegraph.forgegraf.com

Deployed 1b1bb220 with the beta stage's environment. It redeploys on every push and is destroyed when this PR closes.

Preview environment is live: https://pr-745-forgegraph.forgegraf.com Deployed `1b1bb220` with the beta stage's environment. It redeploys on every push and is destroyed when this PR closes.
Sign in to join this conversation.
No description provided.