crewai - ✅(Solved) Fix [BUG] BrightData SERP tool uses JavaScript template syntax in Python f-strings, breaking all search queries [2 pull requests, 1 comments, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
crewAIInc/crewAI#5269Fetched 2026-04-08 02:51:33
View on GitHub
Comments
1
Participants
1
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×2commented ×1referenced ×1

The get_search_url method in BrightDataSearchTool uses ${query} (JavaScript template literal syntax) instead of {query} (Python f-string syntax) when building search URLs. This causes every search query to be prepended with a literal $ character.

For example, searching for "AI news" produces:

https://www.google.com/search?q=$AI%20news

instead of:

https://www.google.com/search?q=AI%20news

All three search engines (Google, Bing, Yandex) are affected.

Root Cause

The get_search_url method in BrightDataSearchTool uses ${query} (JavaScript template literal syntax) instead of {query} (Python f-string syntax) when building search URLs. This causes every search query to be prepended with a literal $ character.

For example, searching for "AI news" produces:

https://www.google.com/search?q=$AI%20news

instead of:

https://www.google.com/search?q=AI%20news

All three search engines (Google, Bing, Yandex) are affected.

Fix Action

Fixed

PR fix notes

PR #5271: fix: remove erroneous $ in BrightData SERP search URL f-strings

Description (problem / solution / changelog)

Summary

Fixes #5269

The get_search_url() method in BrightDataSearchTool was using JavaScript template literal syntax (${query}) instead of Python f-string syntax ({query}). This caused every search URL to contain a literal $ before the query string, e.g. ?q=$test instead of ?q=test.

All three search engine paths (Google, Bing, Yandex) had the same issue.

Changes

  • Removed the $ prefix from all three f-string interpolations in get_search_url() (lines 134, 136, 137 of brightdata_serp.py)

That's it — three characters removed. No behavioral changes beyond fixing the URLs.

Test plan

  • Verified no other ${...} patterns exist in the BrightData tool files
  • Confirmed the fix produces correct URLs by inspection:
    >>> query = "AI+news"
    >>> f"https://www.google.com/search?q={query}"
    'https://www.google.com/search?q=AI+news'
  • Existing CI should pass (no test changes)

Changed files

  • lib/crewai-tools/src/crewai_tools/tools/brightdata_tool/brightdata_serp.py (modified, +3/-3)

PR #5273: fix: remove $ prefix from f-strings in BrightDataSearchTool.get_search_url

Description (problem / solution / changelog)

Summary

Fixes #5269

The get_search_url method in BrightDataSearchTool used JavaScript template literal syntax (${query}) instead of Python f-string syntax ({query}) when building search URLs. This caused every search query to be prepended with a literal $ character (e.g. ?q=$AI%20news instead of ?q=AI%20news). All three search engines (Google, Bing, Yandex) were affected.

The fix removes the erroneous $ from all three f-strings.

Added 4 tests to cover the fix:

  • Unit tests for get_search_url on each engine verifying correct URL format
  • Integration test through _run verifying the URL sent to the API has no $ prefix

Review & Testing Checklist for Human

  • Verify the three f-string changes in brightdata_serp.py lines 133-137 look correct (removed $ only, nothing else changed)
  • Optionally run BrightDataSearchTool with a real API key to confirm queries work end-to-end without the $ prefix

Link to Devin session: https://app.devin.ai/sessions/0f820d69f9f74596a25ecab76c3fed67

<!-- CURSOR_SUMMARY -->

[!NOTE] Low Risk Low risk: fixes a small URL formatting bug and adds focused tests; behavioral change is limited to removing an unintended $ character in outgoing search queries.

Overview Fixes BrightDataSearchTool.get_search_url to use proper Python f-string interpolation ({query}) for Google/Bing/Yandex, removing the accidental literal $ prefix that was being sent in search queries.

Adds unit tests for each engine’s URL formatting and an _run flow test to assert the request payload URL is encoded correctly and contains no $ in the query.

<sup>Reviewed by Cursor Bugbot for commit 1386a4325ba52e178af0d28d1a8bf8e43723157a. Bugbot is set up for automated code reviews on this repo. Configure here.</sup>

<!-- /CURSOR_SUMMARY -->

Changed files

  • lib/crewai-tools/src/crewai_tools/tools/brightdata_tool/brightdata_serp.py (modified, +3/-3)
  • lib/crewai-tools/tests/tools/brightdata_serp_tool_test.py (modified, +54/-0)

Code Example

https://www.google.com/search?q=$AI%20news

---

https://www.google.com/search?q=AI%20news

---

# Current code (brightdata_serp.py, lines 132-137)
def get_search_url(self, engine: str, query: str) -> str:
    if engine == "yandex":
        return f"https://yandex.com/search/?text=${query}"  # <-- JS syntax
    if engine == "bing":
        return f"https://www.bing.com/search?q=${query}"    # <-- JS syntax
    return f"https://www.google.com/search?q=${query}"       # <-- JS syntax

---

>>> query = "test"
>>> f"https://www.google.com/search?q=${query}"
'https://www.google.com/search?q=$test'
>>> f"https://www.google.com/search?q={query}"
'https://www.google.com/search?q=test'
RAW_BUFFERClick to expand / collapse

Description

The get_search_url method in BrightDataSearchTool uses ${query} (JavaScript template literal syntax) instead of {query} (Python f-string syntax) when building search URLs. This causes every search query to be prepended with a literal $ character.

For example, searching for "AI news" produces:

https://www.google.com/search?q=$AI%20news

instead of:

https://www.google.com/search?q=AI%20news

All three search engines (Google, Bing, Yandex) are affected.

Steps to Reproduce

  1. Set up BRIGHT_DATA_API_KEY and BRIGHT_DATA_ZONE environment variables
  2. Create a BrightDataSearchTool and call it with any query
  3. Inspect the URL being sent to the Bright Data API

Expected behavior

The search URL should contain the query string without any $ prefix. get_search_url("google", "test") should return https://www.google.com/search?q=test.

Screenshots/Code snippets

# Current code (brightdata_serp.py, lines 132-137)
def get_search_url(self, engine: str, query: str) -> str:
    if engine == "yandex":
        return f"https://yandex.com/search/?text=${query}"  # <-- JS syntax
    if engine == "bing":
        return f"https://www.bing.com/search?q=${query}"    # <-- JS syntax
    return f"https://www.google.com/search?q=${query}"       # <-- JS syntax

Operating System

Ubuntu 22.04

Python Version

3.12

crewAI Version

1.13.0

crewAI Tools Version

1.13.0

Virtual Environment

Venv

Evidence

In Python, f"...${query}" produces a literal $ followed by the interpolated value. Only {query} (without $) is correct f-string syntax. This can be verified in a Python shell:

>>> query = "test"
>>> f"https://www.google.com/search?q=${query}"
'https://www.google.com/search?q=$test'
>>> f"https://www.google.com/search?q={query}"
'https://www.google.com/search?q=test'

Possible Solution

Remove the $ prefix from all three f-strings in get_search_url. I have a fix ready and will open a PR shortly.

Additional context

Looks like the ${} syntax was carried over from a JavaScript codebase or written by someone used to JS template literals. The fix is straightforward — just removing the three $ characters.

extent analysis

TL;DR

Remove the $ prefix from the f-strings in the get_search_url method to fix the issue.

Guidance

  • Verify the fix by checking the generated search URLs for the absence of the $ prefix.
  • Update the get_search_url method to use the correct Python f-string syntax, replacing ${query} with {query} for all three search engines.
  • Test the updated method with different search queries to ensure the fix works as expected.
  • Review the codebase for any other instances of JavaScript template literal syntax being used incorrectly in Python code.

Example

def get_search_url(self, engine: str, query: str) -> str:
    if engine == "yandex":
        return f"https://yandex.com/search/?text={query}"
    if engine == "bing":
        return f"https://www.bing.com/search?q={query}"
    return f"https://www.google.com/search?q={query}"

Notes

This fix assumes that the issue is solely due to the incorrect use of JavaScript template literal syntax in the Python code. If other issues arise after applying this fix, further investigation may be necessary.

Recommendation

Apply the workaround by removing the $ prefix from the f-strings in the get_search_url method, as this is a straightforward and targeted fix for the identified issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

The search URL should contain the query string without any $ prefix. get_search_url("google", "test") should return https://www.google.com/search?q=test.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING