Skip to content

fix: prioritize specific child errors over branch required errors in anyOf (#153) - #342

Open
utkarshpatwa393-sys wants to merge 1 commit into
atlassian:mainfrom
utkarshpatwa393-sys:fix/anyof-deepest-path-153
Open

utkarshpatwa393-sys wants to merge 1 commit into
atlassian:mainfrom
utkarshpatwa393-sys:fix/anyof-deepest-path-153

Conversation

@utkarshpatwa393-sys

Copy link
Copy Markdown

Fixes #153 (and addresses #81).

Summary of Changes

When validating against an anyOf or oneOf schema where an unselected branch specifies required properties, Ajv emits required errors at the parent node alongside anyOf errors. Previously, filterRedundantErrors treated all required errors as having absolute priority over child errors, emptying root.children and masking specific validation errors (e.g., type, enum, etc.) on properties that the user actually provided in their payload.

This PR:

  1. Distinguishes direct object-level required errors from branch-specific required errors (schemaPath containing /anyOf/ or /oneOf/).
  2. Preserves specific child errors when branch-level required errors coexist with child errors from alternative branches.
  3. If no child errors exist, branch-level required errors are retained as expected.
  4. Adds regression tests covering deeply nested anyOf failure resolution.

All existing and new tests pass cleanly with 100% typecheck and lint conformance.

…ssian#153)

Signed-off-by: Utkarsh patwa <utkarshpatwa393@gmail.com>
@changeset-bot

changeset-bot Bot commented Nov 8, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 2abb721

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

This branch has not been deployed

No deployments
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.

Misleading error when describing deeply nested anyOf failure

1 participant