{"record":{"id":"7eb958c78c3f43ad","repo":"HKUDS/Vibe-Trading","slug":"invalid-local-connection-id-connection-id-or","errorCode":null,"errorMessage":"invalid local connection id: {connection_id or '?'}","messagePattern":"invalid local connection id: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/trading/connections.py","lineNumber":306,"sourceCode":"    def _parse(raw: object) -> TradingConnection:\n        \"\"\"Validate one registry row.\n\n        Args:\n            raw: Decoded registry row.\n\n        Returns:\n            The validated connection.\n\n        Raises:\n            ValueError: If the row is not an object, carries an invalid id or\n                label, names an unknown or ineligible profile, or claims a\n                credential reference that does not match its transport.\n        \"\"\"\n        if not isinstance(raw, dict):\n            raise ValueError(\"each local connection must be an object\")\n        connection_id = str(raw.get(\"id\") or \"\").strip().lower()\n        if not _ID_RE.fullmatch(connection_id):\n            raise ValueError(f\"invalid local connection id: {connection_id or '?'}\")\n        profile_id = str(raw.get(\"profile_id\") or \"\").strip().lower()\n        profile = profile_by_id(profile_id)\n        if not is_portfolio_connection_profile(profile):\n            raise ValueError(\n                f\"connection profile is not eligible for read-only portfolios: {profile_id}\"\n            )\n        label = str(raw.get(\"label\") or profile.label).strip()\n        if (\n            not label\n            or len(label) > 80\n            or any(ord(character) < 32 for character in label)\n        ):\n            raise ValueError(\n                \"connection label must contain 1 to 80 printable characters\"\n            )\n        expected_ref = _credential_reference(profile.id, connection_id)\n        credential_ref = str(raw.get(\"credential_ref\") or expected_ref)\n        if (","sourceCodeStart":288,"sourceCodeEnd":324,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/trading/connections.py#L288-L324","documentation":"Raised while parsing a persisted connection entry whose id fails the _ID_RE format check after trimming and lowercasing. Connection ids must be machine-friendly identifiers (the regex typically allows lowercase alphanumerics, digits, hyphens/underscores), so ids with spaces, symbols, or empty values are rejected.","triggerScenarios":"A settings entry with \"id\": \"\", \"id\": null, or an id containing characters outside _ID_RE (e.g. \"Alpaca Main!\", \"alpaca/props\", trailing emoji) hits the fullmatch check in _parse during list() or save().","commonSituations":"Hand-editing the settings file with a human-readable label in the id field; upstream tools writing unslugified names; copy-pasting ids with invisible whitespace or unicode characters; an empty id after whitespace-only input.","solutions":["Set the id to a lowercase slug: letters, digits, hyphen/underscore only (e.g. \"alpaca-paper\")","Ensure id is non-empty after stripping whitespace","If unsure of the exact regex, read _ID_RE in connections.py and match your id against it","Regenerate the entry via store.create() which validates/normalizes ids for you"],"exampleFix":"// before\n{\"id\": \"Alpaca Main!\", \"profile_id\": \"paper\"}\n\n// after\n{\"id\": \"alpaca-main\", \"profile_id\": \"paper\"}","handlingStrategy":"validation","validationCode":"import re\nID_RE = re.compile(r\"[a-z0-9][a-z0-9_-]*\")  # mirror _ID_RE from connections.py\ndef valid_connection_id(value: str) -> bool:\n    return bool(ID_RE.fullmatch(value.strip().lower())) and bool(value.strip())","typeGuard":"def is_valid_connection_id(value: object) -> bool:\n    return (\n        isinstance(value, str)\n        and bool(value.strip())\n        and all(32 < ord(c) < 127 for c in value)\n        and value == value.strip().lower()\n    )","tryCatchPattern":"try:\n    store.save(entries)\nexcept ValueError as exc:\n    if str(exc).startswith(\"invalid local connection id\"):\n        # re-generate ids as slugs and retry\n        ...","preventionTips":["Generate ids programmatically as lowercase slugs","Validate ids in UI forms before persisting","Keep labels in the label field, never in id"],"tags":["python","validation","identifier-format","configuration"],"backgroundTag":"invalid-identifier-format","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}