Repository navigation
fix(dom): keep unparseable deeply nested lines during markdown extraction - #5534
Open
pacocartones wants to merge 1 commit into
Open
pacocartones wants to merge 1 commit into
pacocartones wants to merge 1 commit into
Conversation
pacocartones
force-pushed
the
fix/markdown-extract-recursionerror
branch
from
August 28, 2026 08:10
648eb12 to
c93da2b
Compare
|
👋 This PR has been automatically marked as stale because it hasn't had activity for 45 days. To keep this PR open:
This will be automatically closed in 14 days if no further activity occurs. Thanks for contributing to browser-use! 🤖 |
…tion json.loads raises RecursionError, not ValueError, once a line nests past its scanner limit. The SPA-JSON-blob filter in _preprocess_markdown_content only caught ValueError, so page text such as a long run of [[[[... escaped the handler and propagated out of extract_clean_markdown, failing the whole extract action for that page. Treat RecursionError the same way as a decode error: the line is not JSON we can parse, so keep it.
pacocartones
force-pushed
the
fix/markdown-extract-recursionerror
branch
from
October 13, 2026 05:41
c93da2b to
22b4211
Compare
This branch has not been deployed
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.
The SPA-JSON-blob filter in
_preprocess_markdown_contentdrops long lines that parse as JSON, keeping the rest. It guardsjson.loadswithexcept ValueError, butjson.loadsraisesRecursionError— not aValueErrorsubclass — once a line nests past the scanner's limit.So a page whose text contains a long deeply nested run (e.g.
[[[[…) makes the exception escape_preprocess_markdown_content, propagate throughconvert_html_to_markdownandextract_clean_markdown, and fail the entireextractaction for that page. Page content is untrusted input, so this is trivially triggerable.Treating
RecursionErrorlike a decode error matches the intent: if we can't parse it, it isn't a blob we should drop.Test:
tests/ci/test_markdown_extractor.py::TestPreservesLinksAndEncoding::test_preserves_deeply_nested_bracket_lines— fails withRecursionErrorbefore the change, passes after. Pure unit test, no browser:uv run pytestgoes from1 failed, 14 passedto15 passed.ruff format --checkandruff checkclean.Summary by cubic
Prevents markdown extraction from failing on deeply nested bracket runs by treating
json.loadsRecursionErroras a decode failure in the SPA-JSON-blob filter. Previously such lines raisedRecursionError, escaped_preprocess_markdown_content, and abortedextract_clean_markdown; now they are kept and extraction continues.(ValueError, RecursionError)aroundjson.loadsand keep unparseable lines.tests/ci/test_markdown_extractor.py::TestPreservesLinksAndEncoding::test_preserves_deeply_nested_bracket_lines.Written for commit 22b4211. Summary will update on new commits.