Skip to content

fix(check): report a mapping's type mismatch whatever its entries say - #6

Merged
adammharris merged 1 commit into
masterfrom
agent/backlog-a-wrong-entry-hides-its-mappings-mismatch
Nov 11, 2026
Merged

adammharris merged 1 commit into
masterfrom
agent/backlog-a-wrong-entry-hides-its-mappings-mismatch

Conversation

@adammharris

Copy link
Copy Markdown
Member

What changed

judge in src/check.rs drops a container's own type mismatch in favour of its descendants' only when the container is a list. A mapping that does not fit its rule's type now reports its own mismatch whether or not an entry beneath it also mismatches.

Why

The drop exists because a type admits a list whose every item fits (FieldType::admits), so a list that does not fit has an item that has already reported at its own path. No type admits a mapping by its entries, so a mapping under a scalar type is wrong for its own reason. Applied to mappings, the drop hid the mapping's error as soon as any entry was also wrong, and check disagreed with explain.

Behavioural change: Schema::check gains a verdict at a mapping's path in that case (recorded as a Behavioural-change: trailer on the commit).

Closes

docs/tasks/a-wrong-entry-hides-its-mappings-mismatch.md (marked status: done in this branch).

Verification

  • New test a_mappings_type_mismatch_is_reported_whatever_its_entries_say covers both repros from the task (meta.** typed str, and the root under **), plus a list under the same rule still reported once at its item. It failed before the fix and passes after.
  • The task's CLI repro: fig-schema check --schema m.yaml m2.yaml now lists meta.author: expected str, found int and meta: expected str, found map, matching explain.
  • ship ci: all 5 jobs pass (fmt, clippy -D warnings, test, doc, MSRV 1.88).

judge dropped a container's type mismatch whenever any descendant had
reported one. That holds for a list, which a type admits when every item
fits, so a list that does not fit has an item that has already said so. It
does not hold for a mapping: no type admits one by its entries, so a mapping
under a scalar type is wrong for its own reason. A mapping with a wrong entry
then went unreported, and check disagreed with explain. The drop now applies
to lists only.

Closes docs/tasks/a-wrong-entry-hides-its-mappings-mismatch.md.

Behavioural-change: Schema::check now reports a mapping's own type mismatch even when an entry beneath it also mismatches, so such a document gains a verdict at the mapping's path.
@adammharris
adammharris merged commit 3d832bc into master Nov 11, 2026
6 checks passed
@adammharris
adammharris deleted the agent/backlog-a-wrong-entry-hides-its-mappings-mismatch branch November 11, 2026 17:03
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.

1 participant