{"record":{"id":"eef09390d82f4cc9","repo":"HKUDS/Vibe-Trading","slug":"model-generated-at-must-be-timezone-aware-e-g","errorCode":null,"errorMessage":"{model}: generated_at must be timezone-aware (e.g. datetime.now(timezone.utc)), got a naive datetime {value!r} -- an artifact's timestamp must be unambiguous.","messagePattern":"(.+?): generated_at must be timezone-aware \\(e\\.g\\. datetime\\.now\\(timezone\\.utc\\)\\), got a naive datetime (.+?) -- an artifact's timestamp must be unambiguous\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"agent/src/quantlib/valuation/artifact.py","lineNumber":358,"sourceCode":"    Args:\n        value: The candidate ``generated_at``.\n        model: Name of the calling builder, for the error message.\n\n    Returns:\n        ``value`` unchanged.\n\n    Raises:\n        TypeError: If ``value`` is not a ``datetime.datetime``.\n        ValueError: If ``value`` is timezone-naive.\n    \"\"\"\n    if not isinstance(value, datetime):\n        raise TypeError(\n            f\"{model}: generated_at must be a datetime.datetime supplied by the \"\n            f\"caller, got {type(value).__name__}. This module never calls \"\n            \"datetime.now() -- pass datetime.now(timezone.utc) yourself.\"\n        )\n    if value.tzinfo is None or value.utcoffset() is None:\n        raise ValueError(\n            f\"{model}: generated_at must be timezone-aware (e.g. \"\n            \"datetime.now(timezone.utc)), got a naive datetime \"\n            f\"{value!r} -- an artifact's timestamp must be unambiguous.\"\n        )\n    return value\n\n\n# ---------------------------------------------------------------------------\n# Canonical normalization: numbers, then the recursive flatten/hash engine\n# ---------------------------------------------------------------------------\n\n\ndef _normalize_number(value: float) -> str:\n    \"\"\"Canonicalise one number for hashing.\n\n    Fixed 12-significant-digit scientific notation, independent of magnitude,\n    so ``int`` and ``float`` inputs representing the same economic value hash\n    identically, and ``-0.0`` collapses to ``0.0``. 12 significant digits is","sourceCodeStart":340,"sourceCodeEnd":376,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/quantlib/valuation/artifact.py#L340-L376","documentation":"generated_at must be timezone-aware: a datetime whose tzinfo or utcoffset() is None is rejected. Naive timestamps are ambiguous across systems and would make artifact ordering and hashing non-reproducible, hence the ValueError.","triggerScenarios":"build_dcf_artifact(generated_at=datetime(2026, 1, 1), ...) with no tzinfo; datetime.fromisoformat(\"2026-01-01T00:00:00\") which yields a naive datetime; a database driver returning naive datetimes.","commonSituations":"SQLite/CSV/JSON round-trips that strip timezones; test fixtures with naive datetimes; pandas Timestamps converted without tz.","solutions":["Use datetime.now(timezone.utc).","Attach a timezone: value.replace(tzinfo=timezone.utc) only when you know the value is UTC; otherwise use zoneinfo to localize correctly.","When parsing ISO strings, ensure they include an offset (e.g. '2026-01-01T00:00:00+00:00')."],"exampleFix":"# before\nbuild_dcf_artifact(generated_at=datetime(2026, 1, 1), ...)\n# after\nfrom datetime import datetime, timezone\nbuild_dcf_artifact(generated_at=datetime(2026, 1, 1, tzinfo=timezone.utc), ...)","handlingStrategy":"validation","validationCode":"from datetime import datetime, timezone\nif isinstance(generated_at, datetime) and generated_at.tzinfo is None:\n    generated_at = generated_at.replace(tzinfo=timezone.utc)  # only if value is known UTC","typeGuard":"from datetime import datetime\ndef is_timezone_aware(dt) -> bool:\n    return isinstance(dt, datetime) and dt.tzinfo is not None and dt.utcoffset() is not None","tryCatchPattern":null,"preventionTips":["Default to datetime.now(timezone.utc) everywhere.","Store/parse ISO 8601 strings with offsets; avoid naive datetimes from DB/JSON paths."],"tags":["python","datetime","timezone","naive-datetime"],"backgroundTag":"naive-datetime-rejected","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}