Skip to content

Conversation

@rbushri
Copy link

@rbushri rbushri commented Aug 28, 2025

Summary

Fixes #1116 , #1178- Fixed incorrect URL variable used for extraction when processing raw HTML content. The extraction strategy was receiving the full HTML content as the URL parameter instead of the properly formatted URL identifier.

List of files changed and why

rawl4ai/async_webcrawler.py - Fixed line 610 to use _url instead of url in the extraction strategy call. The _url variable correctly handles raw HTML cases by displaying "Raw HTML" instead of passing the entire HTML content as the URL parameter.

How Has This Been Tested?

Local Testing:

  • Tested the fix locally by running crawl4ai with raw HTML content using the raw: prefix
  • Verified that the extraction strategy now receives "Raw HTML" as the URL parameter instead of the full HTML content
  • Confirmed that the content sent to LLM extraction strategies is significantly reduced (no longer includes the full HTML as URL parameter)
  • Tested that normal URL crawling (non-raw HTML) continues to work as expected with the actual URL being passed to extraction strategies

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added/updated unit tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Summary by CodeRabbit

  • Bug Fixes
    • Corrected the context passed to content extraction when processing raw HTML, improving accuracy and consistency of extracted data.
    • Resolves unexpected behaviors in extractors that rely on URL signals, leading to more reliable results for raw HTML inputs.
    • Normal URL-based crawling remains unchanged; no action required from users.
    • No changes to public APIs.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 28, 2025

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The extraction call in crawl4ai/async_webcrawler.py’s aprocess_html now passes _url instead of url to extraction_strategy.run, ensuring raw HTML inputs use a placeholder ("Raw HTML") while normal URL flows remain unchanged. No other logic, signatures, or control flow were modified.

Changes

Cohort / File(s) Summary
Extraction URL context fix
crawl4ai/async_webcrawler.py
In aprocess_html, changed extraction_strategy.run argument from url to _url to pass correct URL context for raw HTML; no other logic altered.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Caller
  participant Crawler as AsyncWebCrawler
  participant Strategy as ExtractionStrategy

  Caller->>Crawler: aprocess_html(input, url, is_raw_html)
  alt is_raw_html
    note right of Crawler: Set _url = "Raw HTML"
  else not raw
    note right of Crawler: Set _url = url
  end
  Crawler->>Strategy: run(preferred_content, _url)
  Strategy-->>Crawler: extraction result
  Crawler-->>Caller: result
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Assessment against linked issues

Objective Addressed Explanation
Use _url instead of url when processing raw HTML to avoid passing full HTML as URL [#1116]

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
None detected All observed edits align with #1116’s objective.

Poem

I nibbled on bytes, a curious spree,
Swapped a tiny var—now lighter the sea!
No more HTML stuffed in the URL stew,
The extractor hums, lean, swift, and true.
Thump-thump goes my paw—ship it, whee! 🐇✨

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between e651e04 and 94534bc.

📒 Files selected for processing (1)
  • crawl4ai/async_webcrawler.py (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
crawl4ai/async_webcrawler.py (1)
crawl4ai/extraction_strategy.py (5)
  • run (79-95)
  • run (109-113)
  • run (461-473)
  • run (726-781)
  • run (1047-1066)
🔇 Additional comments (1)
crawl4ai/async_webcrawler.py (1)

618-618: Fix is correct: pass _url to extraction strategy for raw HTML.

This prevents leaking the full raw HTML via the url param into extraction strategies while preserving the normal URL path. Matches the PR objective.

@rbushri rbushri changed the base branch from main to develop August 28, 2025 08:29
@rbushri rbushri force-pushed the fix/wrong_url_raw branch from c2bcfb5 to 9c3cacd Compare August 28, 2025 08:57
- Prevents full HTML content from being passed as URL to extraction strategies
- Added unit tests to verify raw HTML and regular URL processing

Fix: Wrong URL variable used for extraction of raw html
@rbushri rbushri requested a review from rbushria September 1, 2025 20:17
@GirishPatel
Copy link

GirishPatel commented Oct 16, 2025

This is a very important PR. It enables to send raw html for extraction. Please merge.

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.

[Bug]: Wrong URL variable used for extraction of raw html

3 participants