{"record":{"id":"40d40c4b04ef8131","repo":"HKUDS/Vibe-Trading","slug":"unknown-delivery-status-raw-status-r","errorCode":null,"errorMessage":"unknown delivery status {raw_status!r}","messagePattern":"unknown delivery status (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/scheduled_research/models.py","lineNumber":279,"sourceCode":"            data: A raw dict as produced by :meth:`to_dict`, or ``None`` for a\n                record written before delivery existed.\n\n        Returns:\n            The reconstructed :class:`DeliveryRecord`.\n\n        Raises:\n            TypeError: If a present field has the wrong type.\n            ValueError: If ``status`` is not a recognized value.\n        \"\"\"\n        if not data:\n            return cls()\n        if not isinstance(data, dict):\n            raise TypeError(\"'delivery' must be an object or null\")\n        raw_status = data.get(\"status\", DeliveryStatus.NONE.value)\n        try:\n            status = DeliveryStatus(raw_status)\n        except ValueError as exc:\n            raise ValueError(f\"unknown delivery status {raw_status!r}\") from exc\n        for name in (\"session_id\", \"key\", \"error\", \"provider_message_id\"):\n            value = data.get(name)\n            if value is not None and not isinstance(value, str):\n                raise TypeError(f\"'delivery.{name}' must be a string or null\")\n        updated_at = data.get(\"updated_at\")\n        if updated_at is not None and not isinstance(updated_at, int):\n            raise TypeError(\"'delivery.updated_at' must be an integer (epoch ms) or null\")\n        attempts = data.get(\"attempts\", 0)\n        if isinstance(attempts, bool) or not isinstance(attempts, int) or attempts < 0:\n            raise TypeError(\"'delivery.attempts' must be a non-negative integer\")\n        return cls(\n            status=status,\n            session_id=data.get(\"session_id\"),\n            key=data.get(\"key\"),\n            error=data.get(\"error\"),\n            attempts=attempts,\n            updated_at=updated_at,\n            provider_message_id=data.get(\"provider_message_id\"),","sourceCodeStart":261,"sourceCodeEnd":297,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/scheduled_research/models.py#L261-L297","documentation":"Raised by ScheduledRun delivery from_dict (agent/src/scheduled_research/models.py:279) when the delivery 'status' field is not one of the recognized DeliveryStatus enum values. from_dict maps the raw value through DeliveryStatus(raw_status) and any unknown string or wrong type fails the enum lookup, re-raising as ValueError with the offending value.","triggerScenarios":"Passing delivery = {\"status\": \"SENT\"} (wrong case), {\"status\": \"delivered\"}, {\"status\": 1}, or a newly added status from a newer version being read by an older version. Default when status is absent is DeliveryStatus.NONE, which always succeeds.","commonSituations":"Version skew where a newer writer persists a status the reader's enum doesn't know; hand-edited store files; case mismatches from mapping provider states (e.g. 'sent'/'queued') to internal statuses without normalizing.","solutions":["Use exact enum values (check DeliveryStatus members, e.g. 'none', lowercase forms)","Normalize case and mapping in your writer before persisting","Align reader/writer versions so both know the same status set","Reset the field to the default by omitting 'status' from the stored delivery object"],"exampleFix":"// before\ndelivery = {\"status\": \"SENT\", \"session_id\": sid}\n\n// after\ndelivery = {\"status\": \"sent\", \"session_id\": sid}  # exact enum value","handlingStrategy":"validation","validationCode":"from agent.src.scheduled_research.models import DeliveryStatus\n\ndef valid_status(value):\n    try:\n        DeliveryStatus(value)\n        return True\n    except ValueError:\n        return False","typeGuard":"from agent.src.scheduled_research.models import DeliveryStatus\n\ndef coerce_status(raw):\n    \"\"\"Return a valid DeliveryStatus or the NONE default.\"\"\"\n    try:\n        return DeliveryStatus(raw)\n    except ValueError:\n        return DeliveryStatus.NONE","tryCatchPattern":"try:\n    delivery = DeliveryInfo.from_dict(raw)\nexcept ValueError as exc:\n    if \"unknown delivery status\" in str(exc):\n        raw = dict(raw); raw[\"status\"] = DeliveryStatus.NONE.value\n        delivery = DeliveryInfo.from_dict(raw)\n    else:\n        raise","preventionTips":["Write statuses only via DeliveryStatus.X.value","Keep reader and writer library versions in sync across services","Normalize external provider states to your enum at the ingestion boundary"],"tags":["deserialization","enum","validation","scheduled-research"],"backgroundTag":"invalid-enum-value","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}