[BUG] Scrape tools reject the documented cookies mapping and drop cookies when the URL is passed at runtime
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
Research direction
Start with the cookies handling in lib/crewai-tools/src/crewai_tools/tools/scrape_website_tool/scrape_website_tool.py (around lines 66-67), then make the same change in scrape_element_from_website/scrape_element_from_website.py. Keep the assignment inside the website_url branch so cookies still apply only to a pinned URL, and check that _run passes self.cookies to requests unchanged. Done when a plain {"sessionid": "abc123"} mapping is sent with the request and the tests cover both tools.
Written by the indexing model from the issue text.
Description
Description
ScrapeWebsiteTool and ScrapeElementFromWebsiteTool declare cookies as a plain mapping and document it as such, but their constructors read two literal keys from it and treat the second as the name of an environment variable:
cookies: dict[str, str] | None = None
...
if website_url is not None:
...
if cookies is not None:
self.cookies = {cookies["name"]: os.getenv(cookies["value"]) or ""}
(lib/crewai-tools/src/crewai_tools/tools/scrape_website_tool/scrape_website_tool.py:66-67, identical in scrape_element_from_website/scrape_element_from_website.py:67-68)
The docs describe cookies as "A dictionary containing cookies to be sent with the request" (docs/edge/en/tools/web-scraping/scrapeelementfromwebsitetool.mdx:78), and _run passes self.cookies straight to requests. The documented input therefore fails:
ScrapeWebsiteTool(
website_url="https://example.com",
cookies={"sessionid": "abc123"},
)
# KeyError: 'name'
Only the undocumented shape {"name": "sessionid", "value": "SESSION_COOKIE_ENV_VAR"} produces a cookie, and its value comes from the environment rather than from the caller.
Suggested fix
Store the mapping as given, while keeping the existing restriction that cookies only apply to a tool constructed with a pinned website_url:
if website_url is not None:
...
if cookies is not None:
self.cookies = cookies
Keeping the assignment inside the website_url branch is deliberate: the pinned-URL schema removes website_url from the agent's arguments, so the cookie jar stays scoped to the configured origin. A tool without a pinned URL accepts model-chosen URLs, and attaching developer credentials to those would leak them to an arbitrary host.
A regression test covering both tools is included in the PR.
Prepared with an AI coding agent. Please apply the llm-generated label; this account cannot set repository labels.
- Dominant language
- Python
- Stars
- 60.4k
- Forks
- 9k
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 210
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from crewAIInc/crewAI
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
Maintainers usually reply within 1 day
-
feature-request
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
crewAIInc/crewAI#9200 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
crewAIInc/crewAI#9132 · 5 comments ·
Maintainers usually reply within 1 day
-
[BUG] OpenAI-compatible embedding model alias breaks embedder constructionPossibly taken @gokay-ai claimed this 10 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
crewAIInc/crewAI#8761 · 1 comment ·
Maintainers usually reply within 1 day
-
[FEATURE] Add api_base_url to TavilySearchTool and TavilyExtractorToolPossibly taken @jayfeng7 claimed this 11 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
crewAIInc/crewAI#8635 · 1 comment ·
Maintainers usually reply within 1 day
All issues in crewAIInc/crewAI
Similar issues
-
[Bug] vllm-sr config migrate drops providers.models[].deploymentPossibly taken @Bevisy claimed this today. Openneeds-acceptance wg/developer-experience-ecosystem
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
vllm-project/semantic-router#5996 ·
Maintainers usually reply within 2 days
-
bugfix low-priority plugin:abstract plugin:leyline small-effort source:discussion
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
athola/claude-night-market#1132 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
WeblateOrg/language-data#2773 ·
Maintainers usually reply within 1 day
-
kind/bug priority/medium qa_automation
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
yugabyte/yugabyte-db#37324 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Niko1221/Strata#5553 · 2 comments ·
Maintainers usually reply within 4 days