HKUDS/Vibe-Trading · warning · EtoroAPIError
search query is required
Error message
search query is required
What it means
Raised by search_instruments when the query string, after stripping, is empty. The search API requires a non-empty token.
Source
Thrown at agent/src/trading/connectors/etoro/instruments.py:187
query: Symbol (``BTC``, ``AAPL``), discovery text, or asset-class label
(``crypto``, ``stocks``, ``forex``).
config: Optional connector config.
limit: Max results (capped at 50).
mode: ``auto`` (ticker → exact lookup then fuzzy), ``symbol`` (exact only),
``discover`` (fuzzy ``search`` param only), or ``type`` (browse by
``instrument_type_id`` / asset-class alias).
instrument_type_id: Optional eToro ``instrumentTypeID`` filter (e.g. ``10``
for crypto). When set, uses ``GET /market-data/instruments`` with
``instrumentTypeIds``.
include_rates: When browsing by type, attach bid/ask/last from the flat
``/market-data/instruments/rates`` endpoint (works on all profiles).
"""
from src.trading.connectors.etoro.client import load_config
cfg = config or load_config()
token = str(query or "").strip()
if not token:
raise EtoroAPIError("search query is required")
clean_limit = max(1, min(int(limit), 50))
clean_mode = str(mode or "auto").strip().lower()
if clean_mode not in ("auto", "symbol", "discover", "type"):
raise EtoroAPIError("mode must be 'auto', 'symbol', 'discover', or 'type'")
if clean_mode == "type" or instrument_type_id is not None:
resolved_type_id = instrument_type_id
if resolved_type_id is None:
resolved_type_id = _instrument_type_id_from_query(token, cfg)
if resolved_type_id is None:
raise EtoroAPIError(
"instrument_type_id is required for type browse "
"(e.g. 10 for crypto) or use an asset-class query like 'crypto'"
)
return list_instruments_by_type(
resolved_type_id,
cfg,View on GitHub (pinned to 80ffdda44c)
Solutions
- Validate the query is non-empty before calling search_instruments
- Default the caller's input (e.g. require at least one character in the UI)
Example fix
# before
results = search_instruments(user_query) # user_query may be ''
# after
token = (user_query or '').strip()
if not token:
raise ValueError('enter a search term')
results = search_instruments(token) Defensive patterns
Strategy: validation
Validate before calling
token = (query or '').strip()
if not token:
# skip the call; show 'enter a search term' in UI
return [] Type guard
def is_valid_search_query(q: str | None) -> bool:
return bool(q and q.strip()) Prevention
- Require non-empty input in UI before triggering search
- Strip and check query strings at the boundary of your app
When it happens
Trigger: Calling search_instruments(''), search_instruments(None), or with a whitespace-only query.
Common situations: UI passing an empty search box value; default parameter of '' flowing through; f-string building a query from a missing variable.
Understand the failure class
Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.
Related errors
- mode must be 'auto', 'symbol', 'discover', or 'type'
- unsupported instrument_type_id {type_id}
- symbol is required
- invalid instrument id {instrument_id}
- at least one valid instrument_id is required
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/1055ca6b1372b4d0.
Report an issue: GitHub.