{"record":{"id":"08a320cdd82d23d7","repo":"HKUDS/Vibe-Trading","slug":"end-at-must-be-a-valid-rfc3339-timestamp","errorCode":null,"errorMessage":"end_at must be a valid RFC3339 timestamp","messagePattern":"end_at must be a valid RFC3339 timestamp","errorType":"validation","errorClass":"ValueError","httpStatus":400,"severity":"error","filePath":"agent/src/scheduled_research/service.py","lineNumber":89,"sourceCode":"            executor = None\n    if executor is not None:\n        running = bool(executor.is_running)\n    return {\"enabled\": enabled, \"running\": running, \"executable\": enabled and running}\n\n\ndef _parse_end_at(value: Any) -> int | None:\n    if value in (None, \"\"):\n        return None\n    if isinstance(value, bool):\n        raise ValueError(\"end_at must be RFC3339 text or epoch milliseconds\")\n    if isinstance(value, int):\n        return value\n    if not isinstance(value, str):\n        raise ValueError(\"end_at must be RFC3339 text or epoch milliseconds\")\n    try:\n        parsed = datetime.fromisoformat(value.strip().replace(\"Z\", \"+00:00\"))\n    except ValueError as exc:\n        raise ValueError(\"end_at must be a valid RFC3339 timestamp\") from exc\n    if parsed.tzinfo is None:\n        raise ValueError(\"end_at must include an explicit timezone offset\")\n    return int(parsed.timestamp() * 1000)\n\n\ndef _origin_target(session_id: str | None) -> tuple[str, str, str | None, str]:\n    if not session_id:\n        raise ValueError(\"origin delivery requires the originating session\")\n    host = sys.modules.get(\"api_server\") or sys.modules.get(\"agent.api_server\")\n    service = (\n        host._get_session_service()\n        if host and hasattr(host, \"_get_session_service\")\n        else None\n    )\n    session = service.get_session(session_id) if service else None\n    config = getattr(session, \"config\", None) or {}\n    channel = config.get(\"channel\")\n    target = config.get(\"channel_chat_id\")","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/scheduled_research/service.py#L71-L107","documentation":"The end_at string could not be parsed by datetime.fromisoformat (after replacing a trailing 'Z' with '+00:00'). The value must be a valid RFC3339/ISO-8601 timestamp.","triggerScenarios":"Passing strings like '2026-13-01', 'tomorrow', '12/31/2026', or a malformed ISO string; locale-formatted dates; Python <3.11 rejecting some ISO variants that fromisoformat doesn't support.","commonSituations":"Human-entered dates from chat/UI not normalized; Python versions prior to 3.11 where fromisoformat is strict about formats; copying dates with unusual separators.","solutions":["Use strict RFC3339 with offset: '2026-12-31T00:00:00+00:00' or 'Z' suffix","Pre-validate/normalize user input (dateutil, date-fns) before submitting the draft","Send epoch milliseconds instead if string formatting is fragile in your stack"],"exampleFix":"// before\n{\"end_at\": \"31/12/2026\"}\n// after\n{\"end_at\": \"2026-12-31T00:00:00Z\"}","handlingStrategy":"validation","validationCode":"from datetime import datetime\n\ndef ok(ts: str) -> bool:\n    try:\n        datetime.fromisoformat(ts.strip().replace(\"Z\", \"+00:00\"))\n        return True\n    except ValueError:\n        return False\nassert ok(draft[\"end_at\"])","typeGuard":"def is_rfc3339(s: str) -> bool:\n    try:\n        datetime.fromisoformat(s.strip().replace(\"Z\", \"+00:00\"))\n        return True\n    except ValueError:\n        return False","tryCatchPattern":"try:\n    build_job_from_draft(draft)\nexcept ValueError as e:\n    if \"valid RFC3339\" in str(e):\n        prompt_user_for_date()","preventionTips":["Use standard libraries (date-fns, dateutil) to format RFC3339","Prefer epoch ms when the client's date formatting is unreliable"],"tags":["scheduled-research","validation","datetime","rfc3339"],"backgroundTag":"invalid-timestamp-format","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}