Fix SimpleOutput to drop annotations for items failing contains subschema#612
Open
staging-devin-ai-integration[bot] wants to merge 1 commit intomainfrom
Open
Fix SimpleOutput to drop annotations for items failing contains subschema#612staging-devin-ai-integration[bot] wants to merge 1 commit intomainfrom
staging-devin-ai-integration[bot] wants to merge 1 commit intomainfrom
Conversation
…hema The SimpleOutput collector was incorrectly retaining annotations from items that fail against the contains subschema. This happened because the mask-based early return for the contains context suppressed both the error and the annotation cleanup. The fix adds annotation cleanup within the contains context early return path, filtering by both evaluate_path and instance_location. This ensures annotations are only retained for items that actually pass the contains subschema. Co-Authored-By: bot_apk <apk@cognition.ai>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix SimpleOutput to drop annotations for items failing contains subschema
Summary
The
SimpleOutputcollector was incorrectly retaining annotations (e.g.title) from array items that fail against acontainssubschema. For example, given:{ "contains": { "type": "number", "title": "Test" } }and instance
["foo", 42, true], thetitleannotation was being kept for/0and/2even though those items don't match the contains subschema. Only/1(42) should retain it.Root cause: The
masksystem uses an early return to suppress errors within acontainscontext (since only one match is needed). However, this early return also skipped the annotation cleanup code, so annotations from failing items were never dropped.Fix: Before the early return in the contains mask path (
!entry.second), iterate annotations and erase those matching both the failingevaluate_path(viastarts_with_initial) and the failinginstance_location(viastarts_with). This mirrors the existing cleanup logic but scopes it to the specific instance location that failed.Three new tests are added covering:
Review & Testing Checklist for Human
instance_location.starts_with()filter doesn't over-erase annotations in nested contains scenarios (e.g.containswith object subschemas that produce annotations at sub-paths like/0/foo)minContains/maxContainsedge cases need additional test coverage (sameLoopContainshandler is used, but no explicit tests added)containsmask (!entry.second) and doesn't affectanyOf/oneOf/not/ifpaths which useentry.second == trueNotes
makeconfirms no formatting changes remain