{"record":{"id":"2cee4bc02d9b19f8","repo":"HKUDS/Vibe-Trading","slug":"unsupported-instrument-type-id-type-id","errorCode":null,"errorMessage":"unsupported instrument_type_id {type_id}","messagePattern":"unsupported instrument_type_id (.+?)","errorType":"validation","errorClass":"EtoroAPIError","httpStatus":null,"severity":"warning","filePath":"agent/src/trading/connectors/etoro/instruments.py","lineNumber":264,"sourceCode":"        \"instruments\": normalized[:clean_limit],\n    }\n\n\ndef list_instruments_by_type(\n    instrument_type_id: int,\n    config: EtoroConfig | None = None,\n    *,\n    limit: int = 10,\n    include_rates: bool = False,\n) -> dict[str, Any]:\n    \"\"\"List tradable instruments for an eToro ``instrumentTypeID`` (e.g. ``10`` = crypto).\"\"\"\n    from src.trading.connectors.etoro.client import load_config\n\n    cfg = config or load_config()\n    type_id = int(instrument_type_id)\n    id_to_label, _ = _load_instrument_type_catalog(cfg)\n    if type_id not in id_to_label:\n        raise EtoroAPIError(f\"unsupported instrument_type_id {type_id}\")\n\n    clean_limit = max(1, min(int(limit), 50))\n    payload = make_client(cfg).request(\n        \"GET\",\n        MARKET_DATA_INSTRUMENTS_PATH,\n        params={\"instrumentTypeIds\": type_id},\n        allow_retry=True,\n    )\n    items = _extract_metadata_items(payload)\n    filtered = [\n        item\n        for item in items\n        if isinstance(item, dict) and _instrument_type_id(item) == type_id\n    ]\n    normalized = [_normalize_metadata_row(item) for item in filtered]\n    normalized = [row for row in normalized if row.get(\"instrument_id\") is not None]\n    instruments = normalized[:clean_limit]\n    if include_rates:","sourceCodeStart":246,"sourceCodeEnd":282,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/trading/connectors/etoro/instruments.py#L246-L282","documentation":"Raised by list_instruments_by_type when the provided integer instrument_type_id is not present in the catalog loaded from the eToro API.","triggerScenarios":"list_instruments_by_type(999) with an id that eToro's catalog doesn't contain; stale hardcoded id after eToro changes their taxonomy.","commonSituations":"Hardcoded type ids from older API versions; guessed ids; copy-paste from outdated docs.","solutions":["Call get_instrument_types() to list valid ids and pick from there","Update hardcoded ids to current catalog values"],"exampleFix":"# before\nlist_instruments_by_type(10)  # 10 no longer valid\n# after\nvalid = {t['id'] for t in get_instrument_types()}\nassert 10 in valid\nlist_instruments_by_type(10)","handlingStrategy":"validation","validationCode":"valid = {t['id'] for t in get_instrument_types()}\nif type_id not in valid:\n    raise ValueError(f'{type_id} not in catalog; valid: {sorted(valid)}')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never hardcode type ids without a startup validation against the live catalog","Refresh cached catalog periodically"],"tags":["etoro","instruments","validation"],"backgroundTag":"invalid-resource-id","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}