fix(client): filter oneOf branch sub-errors from Ajv allErrors output#1112
fix(client): filter oneOf branch sub-errors from Ajv allErrors output#1112
Conversation
…tput Fixes #1111: Ajv allErrors:true emits per-branch required/type errors from every non-matching oneOf variant, causing spurious storyboard CI failures for downstream SDKs (e.g. "/products/2/name: must have required property 'name'" on products that have name populated). The oneOf node error is the actionable signal; branch sub-errors are filtered via schemaPath prefix match. https://claude.ai/code/session_01Sv61kPXqT5b8bLYZ62muHV
…tion Code-reviewer pre-PR blocker: the original filter dropped nested oneOf node errors (a oneOf inside a branch of an outer oneOf) because their schemaPath is a descendant of the outer oneOf's path. Fix: guard err.keyword === 'oneOf' so all oneOf node errors are always preserved — only non-oneOf sub-branch errors are subject to the prefix-drop. Also strengthen the regression test: assert.ok on oneOfIssue unconditionally (not inside a silent if-guard) so a future regression that drops the node error itself is caught rather than silently skipped. https://claude.ai/code/session_01Sv61kPXqT5b8bLYZ62muHV
|
Triage update — source issue resolved as not-a-bug. @bokelley closed #1111 after tracing the actual root cause to The Triaged by Claude Code. Session: https://claude.ai/code/session_01WVfLw36MJBxN4oMZGuPUWh Generated by Claude Code |
|
Acknowledged — noted that #1113 ("compact oneOf cascade so real residuals reach the wire") supersedes this draft and issue #1111 is closed. No further action from triage. Generated by Claude Code Generated by Claude Code |
Closes #1111
Summary
filterOneOfSubErrors()insrc/lib/validation/schema-validator.ts, applied in bothvalidateRequestandvalidateResponsebefore error formatting.schemaPathis a strict descendant of a failingoneOfnode's path.oneOfnode errors are always kept (including nested ones via an explicitkeyword === 'oneOf'guard).anyOfsub-errors are intentionally NOT filtered —anyOfallows partial matches and its per-branch errors carry useful disambiguation signal.test/lib/schema-validation.test.jsthat assertsoneOfsub-branch errors are absent fromvalidateRequestoutput and the node error is preserved..changeset/oneof-suberror-filter.md(patch bump for@adcp/sdkand@adcp/client).Root cause
schema-loader.tsinitialises Ajv withallErrors: true. When Ajv evaluates aoneOfand no branch matches it:oneOfnode error (actionable).required/typeerror per property mismatch in every branch it evaluated (noise).These sub-branch errors surfaced as spurious "must have required property" failures in storyboard CI, causing false-negative reports for downstream SDKs.
What was tested
test/lib/schema-validation.test.jssuite (build/unit — schema-dependent assertions are vacuous without synced schemas but not misleading).test/validation-enum-enrichment.test.js— unaffected by this change.npx prettier --writeandnpx tsc --noEmitpass clean on the branch.Pre-PR reviews
Two expert reviews were completed before this PR was opened:
oneOfguard added; test assertion hardened from silent-vacuous toassert.ok).anyOfexclusion justified, no impact oncontext_value_rejectedhint diagnostics.Out of scope / follow-ons
NODE_ENV-sensitivedefaultResponseMode()inclient-hooks.ts(separate CI vs local discrepancy vector — distinct issue).anyOfflooding inget_adcp_capabilitiesresponses (separate scope, different keyword).https://claude.ai/code/session_01Sv61kPXqT5b8bLYZ62muHV
Generated by Claude Code