{"record":{"id":"640df7d5a441999c","repo":"HKUDS/Vibe-Trading","slug":"invalid-instrument-id-instrument-id","errorCode":null,"errorMessage":"invalid instrument id {instrument_id}","messagePattern":"invalid instrument id (.+?)","errorType":"validation","errorClass":"EtoroAPIError","httpStatus":null,"severity":"warning","filePath":"agent/src/trading/connectors/etoro/instruments.py","lineNumber":303,"sourceCode":"    return {\n        \"status\": \"ok\",\n        **_base_payload(cfg),\n        \"instrument_type_id\": type_id,\n        \"instrument_type\": id_to_label[type_id],\n        \"mode\": \"type\",\n        \"instruments\": instruments,\n    }\n\n\ndef resolve_instrument_id(symbol: str, cfg: EtoroConfig) -> int:\n    \"\"\"Resolve a user symbol to an eToro ``instrumentId`` for trading APIs.\"\"\"\n    token = str(symbol or \"\").strip()\n    if not token:\n        raise EtoroAPIError(\"symbol is required\")\n    if token.isdigit():\n        instrument_id = int(token)\n        if instrument_id in _INVALID_INSTRUMENT_IDS or instrument_id < 0:\n            raise EtoroAPIError(f\"invalid instrument id {instrument_id}\")\n        return instrument_id\n\n    canonical = _canonical_ticker(token)\n    candidates: list[tuple[int, int]] = []  # (priority, instrument_id)\n\n    for lookup in _lookup_variants(token, canonical):\n        for item in _search_by_symbol(cfg, lookup, limit=25):\n            instrument_id = _instrument_id(item)\n            if instrument_id is None:\n                continue\n            priority = _match_priority(item, lookup, canonical, token)\n            if priority > 0:\n                candidates.append((priority, instrument_id))\n\n    if not candidates:\n        for item in _search_by_text(cfg, canonical, limit=25):\n            instrument_id = _instrument_id(item)\n            if instrument_id is None:","sourceCodeStart":285,"sourceCodeEnd":321,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/trading/connectors/etoro/instruments.py#L285-L321","documentation":"Raised by resolve_instrument_id when the input is all digits but the resulting integer is negative or in the _INVALID_INSTRUMENT_IDS blocklist (known non-tradeable placeholder ids like 0).","triggerScenarios":"resolve_instrument_id('0'), resolve_instrument_id('-5') after strip of a numeric string in the blocklist; get_quote('0').","commonSituations":"UI defaulting instrument id to 0; parsing a CSV where missing ids become 0; using placeholder ids from sample responses.","solutions":["Use a real positive instrument id from search_instruments or get_instrument_metadata","Guard against 0/placeholder ids in your data pipeline"],"exampleFix":"# before\nresolve_instrument_id('0')\n# after\nresolve_instrument_id(str(search_instruments('BTC')[0]['instrumentId']))","handlingStrategy":"validation","validationCode":"INVALID = {0}\nif sym.strip().lstrip('-').isdigit():\n    val = int(sym)\n    if val < 0 or val in INVALID:\n        raise ValueError(f'placeholder instrument id {val}')","typeGuard":"def is_valid_instrument_id(value: int) -> bool:\n    return value > 0 and value not in _INVALID_INSTRUMENT_IDS","tryCatchPattern":null,"preventionTips":["Treat 0 and negative ids as 'missing data' in your pipeline","Resolve ids via search rather than trusting raw numeric input"],"tags":["etoro","instrument-id","validation"],"backgroundTag":"invalid-resource-id","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}