Repository navigation
fix(eval): parse_json(contains=True) bounds the characters its failed tries scan #707
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
antonwolfy
merged 8 commits into
intel:main
from
antonwolfy:fix/json-contains-scan-cost
Nov 14, 2026
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
475bf87
fix(eval): parse_json(contains=True) bounds the characters its failed…
antonwolfy b99e2d1
fix(eval): charge parse_json(contains=True) tries that fail without a…
vchamarthi c6741e2
test(eval): a contains-JSON scan that gives up fails as not JSON
antonwolfy c0f22ca
fix(eval): the contains-JSON changelog names the answers the scan bud…
antonwolfy e9e2edf
docs(eval): say how a json contains try without a position is charged
xaleryb fe5ff19
Merge branch 'main' into fix/json-contains-scan-cost
xaleryb 1ed2c6a
docs(eval): name the depth-limit case in the contains-JSON changelog
antonwolfy 63b6a04
fix(eval): parse_json(contains=True) stops retrying once the failed t…
antonwolfy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
dokimi/changelog.d/20261113_160000_json-contains-scan-cost.md
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| ### Fixed | ||
|
|
||
| - **`parse_json(contains=True)` no longer costs starts x text length** — the scan was capped at 1000 `{` or `[` tries, but each try on a long text parsed the whole tail before it failed, so `'[' * 900 + '1,' * 100000` took seconds to read as not JSON. The tries that fail now share a budget of 1,000,000 scanned characters (`CONTAINS_JSON_MAX_SCAN`; a try that fails without a position, or on an unterminated string, is charged to the end of the text; the first parse of the whole text is not counted), and the scan reads the text as not JSON once it is spent (failed tries that have scanned exactly 1,000,000 characters have spent it; one try may cross it), as it does at the start cap. A value found after failed tries that scan under the budget in all, and a value of any length when no earlier try failed late, are found as before; a few failed tries are enough to spend it when each reads a long tail. A check whose scan gives up fails as `not JSON`, it is not left unscored as a `regex` check past its limit is: `'[' * 6 + '1,' * 100000 + ' {"a": 1}'` (six tries of 200,000 characters each) found the object before this change and fails now. The same holds for a value before a long run of brackets: a try that hits the depth limit reports no position, so it is charged the rest of the text, and `'[' + '{"a": 1},' + '[' * 1_100_000` reads as not JSON where it found the object before. |
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
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.