Skip to content

fix(bindx): type-check against @contember/* 2.2.0-alpha.17 - #160

Merged
matej21 merged 3 commits into
mainfrom
fix/resource-exhausted-error-type
Nov 3, 2026
Merged

matej21 merged 3 commits into
mainfrom
fix/resource-exhausted-error-type

Conversation

@matej21

@matej21 matej21 commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Why

@contember/schema 2.2.0-alpha.17 adds the ResourceExhausted execution error and the Numeric column type. bindx does not compile against it:

  • ExecutionErrorTypes is a Record<ExecutionErrorType, …> that has to list every execution error type, so it no longer type-checks.
  • columnToTsType in the generator switches over every column type, so Numeric reaches its never branch.

An app on 2.2.0-alpha.17 that type-checks bindx from source (main and exports point at src) fails its build on the first one.

Changes

  • Bump the @contember/* dependencies from 2.1.0-rc.6 to 2.2.0-alpha.17 together, so a single copy of @contember/schema is installed. Bumping @contember/schema alone left the rc.6 siblings with their own nested copies, and the generator failed to type-check.
  • Add ResourceExhausted to ExecutionErrorTypes, which also makes isExecutionErrorType accept it.
  • Classify ResourceExhausted in a new resource_limit category, which is not retryable, with the code RESOURCE_EXHAUSTED. The request went over the engine's memory budget, and sending the same request again goes over it again. ErrorCategory gains a member, so an exhaustive switch over it has to handle resource_limit.
  • Type a Numeric column as string in generated schemas, the same as the Contember client generator, so an exact decimal keeps every digit. The form ColumnType union names Numeric too, and without a handler it keeps the string fallback.
  • ContemberAdapterOptions.client asks only for execute, as ContentClient already does. The GraphQlClient class gained a private member in 2.2.0-alpha.17.
  • Run the Contember engine and CLI images 2.2.0-alpha.17 in CI and docker-compose. The lint job requires them to match @contember/schema.

Verification

  • bun run typecheck: clean.
  • bun run lint: 0 errors. The 13 warnings are in untouched files.
  • bun run test: 2530 pass, 0 fail.
  • Added tests:
    • ResourceExhausted in ExecutionErrorTypes and in its classification, and the code, category and retryability resolveAllErrors() reports for it.
    • columnToTsType for a Numeric column and a list of them.
    • A Numeric form input keeps every digit, and a TypeHandlerMap takes a Numeric handler.

Status

  • Review round 1 (review agent, gpt-6-astra): changes, 1 medium and 2 low findings, all fixed in a46c69a.
  • Review round 2 (review agent, gpt-6-astra): approve on a46c69a.
  • CI: green on a46c69a.
  • Left: merge, then the v0.1.60 release.

🤖 Generated with Claude Code

matej21 and others added 2 commits November 3, 2026 22:54
@contember/schema 2.2.0-alpha.17 adds the `ResourceExhausted` execution
error and the `Numeric` column type. `ExecutionErrorTypes` is a complete
record of the execution error types, and the generator switches over every
column type, so neither compiled against it: an app on that version that
type-checks bindx from source failed its build.

- Bump the @contember/* dependencies from 2.1.0-rc.6 to 2.2.0-alpha.17
  together, so one copy of @contember/schema is installed.
- Add `ResourceExhausted` to `ExecutionErrorTypes`.
- Type a `Numeric` column as `string` in generated schemas, as the
  Contember client generator does, so an exact decimal keeps every digit.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The images have to match @contember/schema, which the previous commit
bumped to 2.2.0-alpha.17: the lint job checks it, and the CLI refuses to
migrate a project on another version.

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

matej21 commented Nov 3, 2026

Copy link
Copy Markdown
Member Author

Review round 1

  • Reviewer: review agent (gpt-6-astra, Codex)
  • Commit: 985130a
  • Verdict: changes

Findings

  1. medium: ResourceExhausted is resolved as retryable. classifyError puts it in unknown, so resolveAllErrors() returns category: 'unknown', retryable: true and no code (packages/bindx/src/errors/types.ts, packages/bindx/src/errors/errorPathResolver.ts). The error means the request exceeded the engine's memory budget, and sending the same request again will hit the budget again.
    Fix: classify it as non-retryable, map it to a RESOURCE_EXHAUSTED code, and test the resolved category, retryability and code.
  2. low: the public ColumnType union in packages/bindx-form/src/types.ts has no Numeric, so a TypeHandlerMap entry for it does not compile. At runtime the default fallback keeps the value as a string.
    Fix: add 'Numeric' and keep the string handling.
  3. low: ContemberAdapterOptions.client requires the concrete GraphQlClient class. A consumer still on an older @contember/graphql-client cannot pass its client, because the class gained a private member. ContentClient already narrows the same dependency to Pick<GraphQlClient, 'execute'>.
    Fix: use that boundary in packages/bindx/src/adapter/ContemberAdapter.ts.

Verified correct

  • The dependency bump is consistent: one @contember/schema (2.2.0-alpha.17) is installed and no rc.6 pins remain.
  • The Numeric → string mapping matches the Contember client generator. Generated entity and role schemas emit string | null.
  • The new tests fail on the base commit.

Checks run

  • bun run typecheck: pass.
  • bun run test: 2525 pass, 0 fail.
  • bun run lint: 0 errors, 13 warnings, all in unchanged files.

`ResourceExhausted` means the request went over the engine's memory budget,
and the same request goes over it again. It fell through to `unknown`, which
is retryable and carries no code. It now has its own `resource_limit`
category, which is not retryable, and the `RESOURCE_EXHAUSTED` code.

Two more consequences of moving to @contember/* 2.2.0-alpha.17:

- The form `ColumnType` union names `Numeric`, so a `TypeHandlerMap` can
  give it a handler. Without one it keeps the string fallback, which keeps
  every digit.
- `ContemberAdapterOptions.client` asks only for `execute`, as
  `ContentClient` already does. The `GraphQlClient` class gained a private
  member, so a client from another @contember/graphql-client version no
  longer matched the class type.

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

matej21 commented Nov 3, 2026

Copy link
Copy Markdown
Member Author

Response to review round 1

  1. medium, ResourceExhausted retryable: fixed in a46c69a. It has its own resource_limit category, which isRetryableCategory treats as not retryable, and getErrorCode maps it to RESOURCE_EXHAUSTED. A new test in errorPathResolver.test.ts checks the category, retryability and code that resolveAllErrors() returns. Note that ErrorCategory gains a member, so a consumer with an exhaustive switch over it gets a compile error until it handles resource_limit.
  2. low, form ColumnType without Numeric: fixed in a46c69a. 'Numeric' is in the union. No handler entry was added: the string fallback already keeps every digit, and the new tests/unit/form/numericColumn.test.tsx checks that. The test's TypeHandlerMap entry fails to type-check without the union member.
  3. low, ContemberAdapterOptions.client: fixed in a46c69a. It is now Pick<GraphQlClient, 'execute'>, the same boundary ContentClient uses.

Also in this round: 04ae9a2 moves the CI and docker-compose Contember images to 2.2.0-alpha.17. The lint job requires them to match @contember/schema, and the CLI refuses to migrate a project on another version.

Checks on a46c69a:

  • bun run typecheck: clean.
  • bun run lint: 0 errors.
  • bun run test: 2530 pass, 0 fail.

@matej21

matej21 commented Nov 3, 2026

Copy link
Copy Markdown
Member Author

Review round 2

  • Reviewer: review agent (gpt-6-astra, Codex)
  • Commit: a46c69a
  • Verdict: approve

Round 1 findings

  1. medium, ResourceExhausted retryable: resolved. It is now a non-retryable resource_limit error with the code RESOURCE_EXHAUSTED, and a regression test covers the category, retryability and code.
  2. low, form ColumnType without Numeric: resolved. Values stay strings, and tests cover parsing, formatting and the public handler-map type.
  3. low, ContemberAdapterOptions.client: resolved. It is now Pick<GraphQlClient, 'execute'>.

No new findings. The full diff origin/main...a46c69a is consistent, and all CI and docker-compose image pins match 2.2.0-alpha.17.

Checks run

  • bun run typecheck: pass.
  • bun run test: 2530 pass, 0 fail.
  • bun run lint: 0 errors, 13 warnings, all in unchanged files.
  • CI on a46c69a: all four jobs green, including the browser tests.

@matej21
matej21 merged commit 7069f7d into main Nov 3, 2026
4 checks passed
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