Skip to content

[BUG] BrightData SERP tool uses JavaScript template syntax in Python f-strings, breaking all search queries #5269

@MilesQLi

Description

@MilesQLi

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions