Skip to content

fix(core): name the failing field in invalid extension config errors - #695

Merged
jimhoyd merged 1 commit into
mainfrom
fix/extension-config-error-path
Sep 25, 2026
Merged

jimhoyd merged 1 commit into
mainfrom
fix/extension-config-error-path

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 24, 2026

Copy link
Copy Markdown
Collaborator

Fixes #693

What changed

  • prepareExtensions (packages/core/src/extensions.ts) no longer discards Ajv errors. It compiles the registration schema with verbose: true and throws extensionConfigError (packages/core/src/config.ts). That function reuses core's describeSchemaError, so the message has the same form as a core schema error:
    Invalid extension configuration at /extensions/mcp/config/servers/default/tools/tool/annotations (additionalProperties): unknown key "cachedHint"; allowed keys: readOnlyHint, destructiveHint, idempotentHint, openWorldHint (run urlcode extensions --json for its configuration schema)
    • The message includes the pointer, the keyword and a reason taken from the schema. Unknown keys also get a did-you-mean suggestion. The rejected value is never echoed. Key names are capped at 64 characters and the pointer shown in the message at 300; the full pointer stays in details.pointer.
  • explain_error has a new extension-config rule, placed before the generic schema rule. It decodes location from the new message and suggests get_extensions then validate, both canonical tool names.
  • Tests: the exact-message assertions in the mcp and admin package tests and in test/extensions.test.ts now check the pointer and keyword. A new test checks that the value is not echoed. A new explain_error test is in test/mcp-next-tools.test.ts.
  • Docs: docs/EXTENSIONS.md shows the new message format. The explain_error families in docs/TOOLING.md now include extension configuration. llms-full.txt is regenerated.

Not changed

  • Invalid extension policy: <name> at <route> still does not name the failing policy field. The same approach would fix it.
  • addon-install.ts still uses ajv.errorsText. It was left alone because another change to that file is in progress.

Evidence (local, macOS, Node 26.8.2)

  • npm run verify exit 0 (root suite 799/799 plus all workspace suites)
  • npm run test:package exit 0

🤖 Generated with Claude Code

An extension config that failed its registration's schema reported only
'Invalid extension configuration: <name>'. Reuse core's schema error
formatting: the message now gives the JSON pointer under
/extensions/<name>/config, the failed Ajv keyword and a schema-derived
reason (with did-you-mean for unknown keys), never the rejected value.
explain_error gains an extension-config rule that decodes the location
and points at get_extensions.

Fixes #693

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@jimhoyd
jimhoyd merged commit 0f89d4e into main Sep 25, 2026
23 checks passed
@jimhoyd
jimhoyd deleted the fix/extension-config-error-path branch September 25, 2026 00:25
jimhoyd pushed a commit that referenced this pull request Sep 25, 2026
…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
jimhoyd added a commit that referenced this pull request Sep 25, 2026
…sion RateLimit policies (#702, #696, #701) (#720)

* refactor(ui): import core extension contract types instead of copying 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

* fix(core): throttle appends its RateLimit policy instead of replacing 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

* fix(core): name the failing field in route auth and extension policy 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

* test(auth): expect the named quota field in route auth errors; update 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

---------

Co-authored-by: Claude <[email protected]>
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.

[Bug]: invalid extension config errors do not name the failing field

1 participant