{"record":{"id":"8ca35f48bbd50c6e","repo":"HKUDS/Vibe-Trading","slug":"connection-label-must-contain-1-to-80-printable-ch","errorCode":null,"errorMessage":"connection label must contain 1 to 80 printable characters","messagePattern":"connection label must contain 1 to 80 printable characters","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/trading/connections.py","lineNumber":319,"sourceCode":"        \"\"\"\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 (\n            credential_ref == CredentialStore.reference(connection_id)\n            and profile.transport != \"local_plugin\"\n        ):\n            credential_ref = expected_ref\n        if credential_ref != expected_ref:\n            raise ValueError(\n                \"connection credential_ref does not match its local transport\"\n            )\n        return TradingConnection(\n            id=connection_id,\n            profile_id=profile.id,\n            label=label,\n            credential_ref=credential_ref,","sourceCodeStart":301,"sourceCodeEnd":337,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/trading/connections.py#L301-L337","documentation":"Raised when a connection's label (falling back to the profile's default label) is empty after stripping, longer than 80 characters, or contains control characters (any codepoint < 32). Labels are meant to be short human-readable printable names.","triggerScenarios":"A settings entry with \"label\": \"   \", a label over 80 chars, or one containing tab/newline/control characters (raw.get(\"label\") empty AND profile.label also empty triggers it too). Hit during _parse from list() or save().","commonSituations":"Whitespace-only labels from form input or env vars; pasting a long descriptive string as a label; labels containing newline or tab characters from spreadsheet/CSV imports; a profile with an empty default label and no explicit override.","solutions":["Set label to 1-80 printable characters, trimmed of leading/trailing whitespace","Strip control characters (tabs/newlines) from the label before saving","Omit label entirely so the profile's default label is used, if that default is valid","Add a UI-side maxlength=80 and printable-character filter on the label field"],"exampleFix":"// before\n{\"id\": \"alpaca\", \"profile_id\": \"paper\", \"label\": \"\\t  \\n\"}\n\n// after\n{\"id\": \"alpaca\", \"profile_id\": \"paper\", \"label\": \"Alpaca paper trading\"}","handlingStrategy":"validation","validationCode":"def valid_label(label: str) -> bool:\n    label = label.strip()\n    return 0 < len(label) <= 80 and all(ord(c) >= 32 for c in label)","typeGuard":"def is_valid_connection_label(value: object) -> bool:\n    return isinstance(value, str) and valid_label(value)","tryCatchPattern":"try:\n    store.create(connection_id, profile_id, label)\nexcept ValueError as exc:\n    if \"1 to 80 printable\" in str(exc):\n        label = \"\".join(c for c in label if ord(c) >= 32).strip()[:80] or profile.label\n        store.create(connection_id, profile_id, label)\n    else:\n        raise","preventionTips":["Enforce maxlength=80 and printable-only input in forms","Sanitize pasted labels (strip tabs/newlines) before saving","Unit-test label edge cases: empty, whitespace-only, 81 chars, control chars"],"tags":["python","validation","label-constraints","configuration"],"backgroundTag":"string-constraint-violation","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}