Skip to content

fix(bindx): support @contember 2.2.0-alpha.19 and declare @contember/schema - #166

Merged
matej21 merged 3 commits into
mainfrom
fix/contember-alpha19-errors
Nov 18, 2026
Merged

matej21 merged 3 commits into
mainfrom
fix/contember-alpha19-errors

Conversation

@matej21

@matej21 matej21 commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

Why

An app moving to @contember/* 2.2.0-alpha.19 fails its typecheck inside @contember/bindx:

  • alpha.19 adds the CheckConstraintViolation execution error. ExecutionErrorTypes is a complete Record of the execution error types, so it no longer compiles (TS2739). At runtime the type was not recognised: isExecutionErrorType returned false and classifyError returned unknown, which is retryable and has no code.
  • @contember/bindx imports @contember/schema (errors/types.ts) without declaring it.

ResourceExhausted, the other error type alpha.19 has over older engines, is already handled on main (since 2.2.0-alpha.17).

What

  • Bump every @contember/* dependency and the Contember engine and CLI images (docker-compose, CI) from 2.2.0-alpha.17 to 2.2.0-alpha.19 together.
  • Classify CheckConstraintViolation as constraint (not retryable) with the CHECK_CONSTRAINT code, like the other constraint violations. The engine reports it with no path, so it resolves to an entity-level error.
  • Declare @contember/schema in @contember/bindx. bindx-client, bindx-generator and example already declare it; no other package imports it.

Nothing else broke on alpha.19: typecheck, lint, the unit/react suite and check:pack pass unchanged.

Decisions

Decision (brief) Where State
"Handle CheckConstraintViolation wherever bindx maps execution error types, the same way as the other constraint violations. Add a test." packages/bindx/src/errors/types.ts (ExecutionErrorTypes, classifyError), packages/bindx/src/errors/errorPathResolver.ts (getErrorCode); tests in tests/unit/errors/ — 0148fb6; both mappings made exhaustive in fa90efe (review round 1) done
"Declare @contember/schema in the package(s) that import it." packages/bindx/package.json — 4093422 done
"Bump @contember/* to 2.2.0-alpha.19 in bindx and fix what breaks." all package.json pins, bun.lock, docker-compose.yaml, .github/workflows/ci.yml — 0148fb6 done (only the error record broke)
"Run the repo's checks (typecheck, tests, lint)" local run, see Verification done
"Open the PR ready for review. Do one review round." this PR see Status
"Do not publish to npm yourself" — not done here; merge and release wait for the maintainer

Verification

Local:

  • bun run typecheck — exit 0
  • bun run lint — 0 errors (13 warnings, all present on main)
  • bun run test — 2560 pass, 0 fail
  • bun run build && bun run check:pack — all 11 packages ok
  • tests/unit/errors/ — 54 pass on fa90efe, including the new CheckConstraintViolation cases

Status

  • Review rounds: round 1 on 4093422 — approve (1 minor, 3 nits; minor and 2 nits fixed in fa90efe, 1 nit won't fix)
  • CI: green on fa90efe (run 44314927021: lint, typecheck, package contents, unit & integration, browser tests)
  • Left before merge: the maintainer's merge decision (base unchanged, no rebase needed)

🤖 Generated with Claude Code

matej21 and others added 3 commits November 18, 2026 14:29
@contember/schema 2.2.0-alpha.19 adds the `CheckConstraintViolation`
execution error, which the engine reports when a write breaks a database
check constraint. `ExecutionErrorTypes` is a complete record of the
execution error types, so bindx no longer compiled against it (TS2739), and
at runtime the type was not recognised: `isExecutionErrorType` returned
false and it was classified `unknown`, which is retryable and has no code.

- Bump the @contember/* dependencies and the Contember engine and CLI images
  from 2.2.0-alpha.17 to 2.2.0-alpha.19 together.
- Classify `CheckConstraintViolation` as a `constraint` error, like the
  other constraint violations, with the `CHECK_CONSTRAINT` code.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`errors/types.ts` derives `ExecutionErrorType` from `Result` in
@contember/schema, and the published source and declarations import it, but
the package did not declare it. A consumer that type-checks bindx resolved it
only when another package happened to hoist it, and failed otherwise.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`classifyError` and `getErrorCode` switched over plain strings with a
default branch, so a new engine error type broke only `ExecutionErrorTypes`
at compile time while these two quietly returned `unknown` and no code.
They now look up `Record<ExecutionErrorType, ...>` maps, so all three fail
the typecheck together.

`isExecutionErrorType` checks own keys: with `in`, inherited names such as
`toString` passed as error types and would now index the maps.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@matej21

matej21 commented Nov 18, 2026

Copy link
Copy Markdown
Member Author

Review round 1

  • Reviewer: independent Claude agent (Opus 5.5, general-purpose), no shared context with the author beyond the brief
  • Commit reviewed: 4093422
  • Verdict: approve

Checked: every place that maps execution error types, engine behaviour at v2.2.0-alpha.19 (check violations are sent with paths: []), undeclared @contember/* imports in src and dist of every published package, version consistency (no alpha.17 left), that the tests fail without the fix, the decisions table, public-repo hygiene.

# Severity Where Finding
1 minor packages/bindx/src/errors/errorPathResolver.ts:177, packages/bindx/src/errors/types.ts:53 getErrorCode and classifyError switch over plain strings with a default, so the next new engine error type breaks only the Record at compile time while these quietly return undefined / unknown. Back them with Record<ExecutionErrorType, …>.
2 nit tests/unit/errors/errorPathResolver.test.ts:387 The test message is Postgres's raw text; for a check defined in the schema the engine sends Check constraint "<name>" on entity <Entity> violated.
3 nit tests/unit/errors/errorClassification.test.ts:76 toHaveLength(9) restates the implementation (pattern predates the PR).
4 nit PR description Two decision rows refer to an internal workflow; rephrase generically.

Out of scope, predates this PR: @contember/bindx-react declares @contember/graphql-client but does not import it.

@matej21

matej21 commented Nov 18, 2026

Copy link
Copy Markdown
Member Author

Response to review round 1

Only minor and nit findings, so no second round.

# Outcome
1 fixed in fa90efe: classifyError and getErrorCode look up Record<ExecutionErrorType, …> maps, so a new engine error type fails the typecheck in all three places. isExecutionErrorType now checks own keys (Object.hasOwn), since with in an inherited name such as toString would pass and index the maps; tests cover toString and constructor.
2 fixed in fa90efe: the test uses the engine's message for a schema-defined check.
3 won't fix: the pattern predates this PR and is out of its scope; the Record type already enforces completeness, so the assertion is redundant but harmless.
4 fixed: the decision rows now say the merge and release wait for the maintainer.

Out-of-scope note (unused @contember/graphql-client in bindx-react): left for a separate change.

Verified on fa90efe: tests/unit/errors/ 54 pass, bun run typecheck exit 0, eslint on the changed paths clean. CI runs on the new head.

@matej21
matej21 merged commit 6408b09 into main Nov 18, 2026
5 checks passed
@matej21
matej21 deleted the fix/contember-alpha19-errors branch November 18, 2026 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant