{"record":{"id":"292ec00cd9618164","repo":"HKUDS/Vibe-Trading","slug":"instrument-type-id-is-required-for-type-browse-e","errorCode":null,"errorMessage":"instrument_type_id is required for type browse (e.g. 10 for crypto) or use an asset-class query like 'crypto'","messagePattern":"instrument_type_id is required for type browse \\(e\\.g\\. 10 for crypto\\) or use an asset-class query like 'crypto'","errorType":"validation","errorClass":"EtoroAPIError","httpStatus":null,"severity":"warning","filePath":"agent/src/trading/connectors/etoro/instruments.py","lineNumber":199,"sourceCode":"    \"\"\"\n    from src.trading.connectors.etoro.client import load_config\n\n    cfg = config or load_config()\n    token = str(query or \"\").strip()\n    if not token:\n        raise EtoroAPIError(\"search query is required\")\n\n    clean_limit = max(1, min(int(limit), 50))\n    clean_mode = str(mode or \"auto\").strip().lower()\n    if clean_mode not in (\"auto\", \"symbol\", \"discover\", \"type\"):\n        raise EtoroAPIError(\"mode must be 'auto', 'symbol', 'discover', or 'type'\")\n\n    if clean_mode == \"type\" or instrument_type_id is not None:\n        resolved_type_id = instrument_type_id\n        if resolved_type_id is None:\n            resolved_type_id = _instrument_type_id_from_query(token, cfg)\n        if resolved_type_id is None:\n            raise EtoroAPIError(\n                \"instrument_type_id is required for type browse \"\n                \"(e.g. 10 for crypto) or use an asset-class query like 'crypto'\"\n            )\n        return list_instruments_by_type(\n            resolved_type_id,\n            cfg,\n            limit=clean_limit,\n            include_rates=include_rates,\n        )\n\n    rows: list[dict[str, Any]] = []\n    lookup_mode = clean_mode\n    if clean_mode == \"auto\":\n        lookup_mode = \"symbol\" if _looks_like_ticker(token) else \"discover\"\n\n    if lookup_mode == \"symbol\":\n        rows = _search_by_symbol(cfg, token, limit=clean_limit)\n        if not rows and clean_mode == \"auto\":","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/trading/connectors/etoro/instruments.py#L181-L217","documentation":"Raised by search_instruments in type-browse mode when instrument_type_id was not supplied and the query token could not be resolved to a known instrument type via the alias catalog.","triggerScenarios":"search_instruments('energy futures', mode='type') where 'energy futures' isn't in the alias map; or calling with instrument_type_id=None in type mode with an unrecognized asset-class word.","commonSituations":"User expects any natural-language phrase to map to a type; alias list doesn't cover the phrase; type ids changed.","solutions":["Pass an explicit instrument_type_id (e.g. 10 for crypto)","Use a recognized asset-class word like 'crypto' or 'stocks'","Fall back to mode='discover' for fuzzy searching"],"exampleFix":"# before\nsearch_instruments('commodities', mode='type')\n# after\nsearch_instruments('commodities', mode='type', instrument_type_id=7)","handlingStrategy":"validation","validationCode":"from src.trading.connectors.etoro.instruments import get_instrument_types\nvalid_ids = {t['id'] for t in get_instrument_types()}\nif desired_type_id not in valid_ids:\n    # fall back to discover mode instead of type mode\n    ...","typeGuard":null,"tryCatchPattern":"try:\n    search_instruments(token, mode='type')\nexcept EtoroAPIError as exc:\n    if 'instrument_type_id is required' in str(exc):\n        results = search_instruments(token, mode='discover')\n    else:\n        raise","preventionTips":["Prefer explicit instrument_type_id over natural-language type guesses","Fall back to discover mode when type resolution fails"],"tags":["etoro","instruments","type-browse"],"backgroundTag":"unresolved-resource-id","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}