fix: drop markdown_v2 access in BasicWebScraper.extract#60
Open
obchain wants to merge 1 commit into
Open
Conversation
`BasicWebScraper.extract` reads `result.markdown_v2.raw_markdown` / `markdown_with_citations`. crawl4ai 0.5.x removed the `markdown_v2` attribute and raises `AttributeError` on access. This is the same bug the `WebScraper` path hits (tracked in sentient-agi#34); `BasicWebScraper` is currently dead code (no callers — only the `ExtractionConfig` dataclass in the same module is imported elsewhere), but the broken access would bite anyone reaching for it. Mirror the fix used in the `WebScraper` cleanup: pull the markdown payload via `getattr(result, 'markdown', None) or getattr(result, 'markdown_v2', None)`, then read the length fields defensively. Older crawl4ai builds that still expose `markdown_v2` keep working through the fallback. Fixes sentient-agi#59
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.
What
Apply the same
markdown_v2→markdowncleanup that #52 lands inWebScraper.extracttoBasicWebScraper.extract. The two paths had byte-identical broken accesses; this PR brings the second one in line.Why
src/opendeepsearch/context_scraping/basic_web_scraper.py:50-51:crawl4ai 0.5.xremovedmarkdown_v2and replaced its__getattr__with a hardAttributeError(full trace already in #34).BasicWebScraperis currently dead —crawl4ai_scraper.pyonly imports theExtractionConfigdataclass that lives in the same module — but the class is public and the bug is real for anyone reaching for it.Closes #59
How
src/opendeepsearch/context_scraping/basic_web_scraper.py:markdown_obj = getattr(result, 'markdown', None) or getattr(result, 'markdown_v2', None)once per resultresult.success and markdown_obj is not Noneraw_markdown/markdown_with_citationswithgetattr(..., '') or ''so a partially-populatedMarkdownGenerationResultdoesn't crash eitherKept narrowly scoped. Did not delete the unused
BasicWebScraperclass itself — that's a separate cleanup the maintainers may want to weigh.Testing
python3 -m py_compile src/opendeepsearch/context_scraping/basic_web_scraper.py— cleangrep -n markdown_v2 src/opendeepsearch/context_scraping/basic_web_scraper.py— only the intentional fallback line remainscrawl4ai 0.5.xand a fakeresultwhosemarkdown_v2accessor raises, the unpatched code re-raises; the patched code now readsresult.markdown.raw_markdown).