Repository navigation
fix(core): name the failing field in validation errors and keep extension RateLimit policies (#702, #696, #701) - #720
Merged
Conversation
… them (#709) packages/ui/src/host/extension.ts kept hand-maintained structural copies of core's extension contract, which had already drifted: its ExtensionRequest lacked core's requestId and env. Import HandlerResult, ExtensionActivation, ExtensionRequest, ExtensionInstance, ExtensionImmutableAssets, ExtensionAuthoringSurface, ExtensionAuthoringContract and RuntimeExtension from @jimhoyd/urlcode/extensions (already the package's peer) and re-export them so ./host's public types are unchanged in name. HeaderPair and TargetName are not exported by that entry point, so derive them from HandlerResult and RuntimeExtension rather than widening core's surface. loadDocument is not exported from @jimhoyd/urlcode/extensions, so the store-screens path keeps importing it from the core root; the screens / storeCollections() design is untouched pending a maintainer decision. The ui test request fixtures now supply requestId and env, which the real ExtensionRequest requires. CONTRACT.md no longer describes the types as a structural copy. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_014jmv9dMggduiprzSsNd7iP
… an extension's (#701) RateLimit and RateLimit-Policy are structured-field lists of named policies. Throttle's response phase used to drop every existing field of those names and add its own "default" member, so the auth extension's per-credential 429 reported throttle's budget instead of the exhausted "credential" one. It now folds prior field lines into one comma-joined list, drops only a member already named "default" (its own), and appends its member. Retry-After and the other headers are unchanged; throttle alone still emits one field each. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_014jmv9dMggduiprzSsNd7iP
…errors (#702, #696) When a oneOf/anyOf matched no branch, schema errors reported Ajv's first branch failure, so `auth: {freshWithinSeconds: 0}` said `auth` must be `true`. Report the deepest branch failure instead, preferring a real check over a bare type/const mismatch; a oneOf that matched several branches is still reported as itself. Applies to core and extension configuration. Extension route policies that fail the policy schema now report the pointer under /routes/<route>/policies/extensions/<name>, the keyword and a schema-derived reason, never the value, like extension config (#695). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_014jmv9dMggduiprzSsNd7iP
… ui status (#702, #709) The auth handler test pinned the pre-#702 message (the union's const branch at /auth); it now asserts the pointer and location name the bearer quota field. The ui status note no longer describes the ./host contract types as structural copies. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_014jmv9dMggduiprzSsNd7iP
This was referenced Sep 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem and change
This PR carries the triage fixes that don't need a maintainer decision.
auth:object on a route (for exampleauth: {bearer: {quota: {requests: 0, …}}}orauth: {freshWithinSeconds: 0}) used to reportauth (const): must be true. That is thetruebranch of thetrue | objectunion.selectSchemaErrorinpackages/core/src/config.tsnow reports the deepest failure among the union's branches, and at equal depth prefers a real check over a bareconst/type/enummismatch. The message now names the field, e.g.route /api/items, auth.bearer.quota.requests (minimum): must be >= 1. AoneOfthat matched more than one branch is still reported as itself. Extension config errors (extensionConfigError) use the same selection.policySchemaused to report onlyInvalid extension policy: <name> at <route>. The newextensionPolicyErrorreports it the way fix(core): name the failing field in invalid extension config errors #695 reports extension config: a pointer under/routes/<route>/policies/extensions/<name>, the keyword, and a reason taken from the schema, never the value. The policy checked is the route's merged one (layers plus theauth:short form), anddocs/EXTENSIONS.mdsays so."default"member to the existingRateLimitandRateLimit-Policylists. It replaces only its own member, and with no other producer it emits one field of each, as before. A handler or extension that sets its own RateLimit policies now keeps them next to throttle's instead of losing them. The [Bug]: core throttle's response phase overwrites RateLimit fields on an extension's 429 #701 limitation is removed frompackages/auth/README.mdanddocs/policies/throttle.md; [Request]: bearer quota follow-ups: per-key budget override and RateLimit fields on allowed responses #703 stays referenced for the remaining gaps.packages/ui/src/host/extension.tsnow imports the core extension contract types from@jimhoyd/urlcode/extensionsinstead of keeping structural copies. The copies had already drifted:ExtensionRequestwas missingrequestIdandenv.HeaderPairandTargetNameare derived from exported types, and core's public surface is unchanged. The store-coupledscreensdesign, the main part of Decouple UI data screens from the store extension's private configuration #709, needs a decision and is not touched, so Decouple UI data screens from the store extension's private configuration #709 stays open.Each fix is its own commit.
Verification
npm run verifyon Node v26.10.0 (with the bundled SQLite that the auth package requires): exit 0. Test summaries: 809, 29, 35, 96, 224, 23, 65 and 3 tests, all with 0 failures.test/extensions.test.ts: route auth errors for the quota,freshWithinSeconds, unknown-key and non-object cases; policy errors forconst,requiredand no-schema, including a check that the rejected value is not in the message.test/policy-throttle.test.ts: [Bug]: core throttle's response phase overwrites RateLimit fields on an extension's 429 #701 member merge and dedupe.packages/auth/test/auth-http.test.ts: end to end, the credential 429 carries both policies. It fails without the fix.packages/auth/test/auth-handler.test.tsused to pin the [Bug]: invalid route auth short form reports 'must be true' instead of the bad field #702 message; it now asserts the named quota field.npm run test:package. No packaging, CLI or starter changes.Compatibility and security
No YAML or schema changes. Error message text changes for invalid
auth:objects, invalid extension policies, and some extension config errors (oneOfcases). Scripts that match the exact old strings would need updating.Header behaviour: a response that already carries
RateLimit/RateLimit-Policyfields now keeps its non-defaultmembers, with throttle's member appended.Policy error messages are built from the schema, never the rejected value, and a test asserts that.
Changes match the documented portable contract; docs/examples are updated where needed.
Relevant tests and package checks pass, or limitations are explained above.
No credentials, customer data or private project material are included.
Runtime/starter changes remain aligned where applicable (no starter-facing change).
🤖 Generated with Claude Code
https://claude.ai/code/session_014jmv9dMggduiprzSsNd7iP
Generated by Claude Code