{"record":{"id":"ea420624fe3633ad","repo":"zylon-ai/private-gpt","slug":"invalid-status-value-valid-options-s-value","errorCode":null,"errorMessage":"Invalid status: {value}. Valid options: {[s.value for s in cls]}","messagePattern":"Invalid status: (.+?)\\. Valid options: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"private_gpt/components/streaming/providers/models.py","lineNumber":67,"sourceCode":"        if not isinstance(other, StreamStatus):\n            return NotImplemented\n        return self._get_order() >= other._get_order()\n\n    def __hash__(self) -> int:\n        return hash(self.value)\n\n    def __str__(self) -> str:\n        \"\"\"Return the string representation of the status.\"\"\"\n        return self.value\n\n    @classmethod\n    def from_string(cls, value: str) -> \"StreamStatus\":\n        \"\"\"Create StreamStatus from string value.\"\"\"\n        normalized = str(value).lower().strip()\n        for status in cls:\n            if status.value == normalized:\n                return status\n        raise ValueError(\n            f\"Invalid status: {value}. Valid options: {[s.value for s in cls]}\"\n        )\n\n\nclass StreamMetadata(BaseModel):\n    correlation_id: str = Field(\n        default_factory=lambda: str(uuid.uuid4()),\n        description=\"Unique identifier for the stream\",\n    )\n    status: StreamStatus = Field(\n        default=StreamStatus.PENDING,\n        description=\"Current status of the stream\",\n    )\n    created_at: datetime = Field(\n        default=datetime.now(UTC),\n        description=\"Timestamp when the stream was created\",\n    )\n    updated_at: datetime = Field(","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/zylon-ai/private-gpt/blob/4a030776a31a901ad80b1bf4d7faa2c1a367efbb/private_gpt/components/streaming/providers/models.py#L49-L85","documentation":"Raised by StreamStatus.from_string when the supplied value, after lowercasing and stripping, does not match any StreamStatus enum member value. The parser is intentionally strict — it lists the accepted values in the message — because status strings drive stream lifecycle logic. It is the standard boundary validator for converting external strings (API payloads, DB rows, env vars) into the enum.","triggerScenarios":"Calling StreamStatus.from_string with values like \"finished\", \"done\", \"Success\" with trailing punctuation, or an empty string. Also raised when deserializing a status persisted by an older version whose vocabulary changed.","commonSituations":"Client sends a status name not in the enum; a renamed enum value across versions invalidates stored data; case/whitespace variants that strip/lower cannot normalize (e.g. \"IN_PROGRESS \" is fine but \"in-progress\" is not).","solutions":["Use only the enum values printed in the error message, e.g. StreamStatus.from_string(\"completed\")","Pre-validate external input against {s.value for s in StreamStatus} and reject early with a clear 400 response","After upgrades, migrate stored status strings or add a mapping layer from legacy names to current enum values"],"exampleFix":"# before\nstatus = StreamStatus.from_string(request_body[\"status\"])  # \"done\" -> ValueError\n# after\nVALID = {s.value for s in StreamStatus}\nraw = request_body[\"status\"].lower().strip()\nif raw not in VALID:\n    raise HTTPException(400, f\"status must be one of {sorted(VALID)}\")\nstatus = StreamStatus.from_string(raw)","handlingStrategy":"type-guard","validationCode":"from private_gpt.components.streaming.providers.models import StreamStatus\n\nVALID_STATUSES = {s.value for s in StreamStatus}\nraw = value.lower().strip()\nif raw not in VALID_STATUSES:\n    raise ValueError(f\"status must be one of {sorted(VALID_STATUSES)}, got {value!r}\")\nstatus = StreamStatus.from_string(raw)","typeGuard":"def is_valid_stream_status(value: str) -> bool:\n    normalized = value.lower().strip()\n    return normalized in {s.value for s in StreamStatus}","tryCatchPattern":"try:\n    status = StreamStatus.from_string(raw)\nexcept ValueError:\n    status = StreamStatus.PENDING  # explicit default, not a silent fallback of data","preventionTips":["Validate status strings at the API boundary with the enum-derived set","Add a mapping table for legacy status names after upgrades"],"tags":["streaming","enum","validation","deserialization"],"backgroundTag":null,"analyzedSha":"4a030776a31a901ad80b1bf4d7faa2c1a367efbb","analyzedAt":"2026-08-15T03:51:26.951Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}