Skip to content

fix(core): name the failing field in validation errors and keep extension RateLimit policies (#702, #696, #701) - #720

Merged
jimhoyd merged 4 commits into
mainfrom
claude/sleepy-shannon-xvazgl
Sep 25, 2026
Merged

jimhoyd merged 4 commits into
mainfrom
claude/sleepy-shannon-xvazgl

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator

Problem and change

This PR carries the triage fixes that don't need a maintainer decision.

Each fix is its own commit.

Verification

  • Full npm run verify on 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.
  • New regression tests:
    • test/extensions.test.ts: route auth errors for the quota, freshWithinSeconds, unknown-key and non-object cases; policy errors for const, required and 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.ts used 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.
  • Not run: 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 (oneOf cases). Scripts that match the exact old strings would need updating.

  • Header behaviour: a response that already carries RateLimit/RateLimit-Policy fields now keeps its non-default members, 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

… 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants