{"record":{"id":"ffa9b8e5933fdae4","repo":"HKUDS/DeepTutor","slug":"avatar-must-be-empty-or-icon-name-color","errorCode":null,"errorMessage":"Avatar must be empty or 'icon:<name>:<color>'","messagePattern":"Avatar must be empty or 'icon:<name>:<color>'","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"deeptutor/api/routers/auth.py","lineNumber":180,"sourceCode":"_ICON_MARKER_RE = re.compile(r\"^icon:[a-z0-9-]{1,32}:[a-z0-9-]{1,32}$\")\n\n# User ids are generated as \"u_<uuid hex>\" (plus the \"local-admin\" /\n# \"env-admin\" sentinels); reject anything else before it reaches the\n# filesystem layer.\n_USER_ID_RE = re.compile(r\"^[A-Za-z0-9_-]{1,64}$\")\n\n\nclass UpdateProfileRequest(BaseModel):\n    \"\"\"Payload for the PUT /profile endpoint.\"\"\"\n\n    avatar: str\n\n    @field_validator(\"avatar\")\n    @classmethod\n    def avatar_valid(cls, v: str) -> str:\n        v = v.strip()\n        if v and not _ICON_MARKER_RE.match(v):\n            raise ValueError(\"Avatar must be empty or 'icon:<name>:<color>'\")\n        return v\n\n\n# ---------------------------------------------------------------------------\n# Shared helper — extract token from cookie or Bearer header\n# ---------------------------------------------------------------------------\n\n\ndef _bearer_token_from_header(authorization: str | None) -> str | None:\n    \"\"\"Parse ``Authorization: Bearer <token>`` without using ``HTTPBearer``.\n\n    ``HTTPBearer`` is a class-based dependency whose ``__call__`` is annotated\n    ``request: Request``. FastAPI doesn't inject a Request into WebSocket\n    dependency resolution, which makes ``HTTPBearer`` raise ``TypeError`` the\n    moment a router with this dep mounts a WS endpoint. Doing the parse by\n    hand keeps ``require_auth`` HTTP/WS-symmetric.\n    \"\"\"\n    if not authorization:","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/api/routers/auth.py#L162-L198","documentation":"Error \"Avatar must be empty or 'icon:<name>:<color>'\" thrown in HKUDS/DeepTutor.","triggerScenarios":"Thrown at deeptutor/api/routers/auth.py:180 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}