{"record":{"id":"7ca8d0a7a843a095","repo":"HKUDS/Vibe-Trading","slug":"model-generated-at-must-be-a-datetime-datetime","errorCode":null,"errorMessage":"{model}: generated_at must be a datetime.datetime supplied by the caller, got {type(value).__name__}. This module never calls datetime.now() -- pass datetime.now(timezone.utc) yourself.","messagePattern":"(.+?): generated_at must be a datetime\\.datetime supplied by the caller, got (.+?)\\. This module never calls datetime\\.now\\(\\) -- pass datetime\\.now\\(timezone\\.utc\\) yourself\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"agent/src/quantlib/valuation/artifact.py","lineNumber":352,"sourceCode":"def _require_generated_at(value: datetime, model: str) -> datetime:\n    \"\"\"Check that a caller-supplied timestamp is usable, and only that.\n\n    This function never reads a clock. Its only job is to reject a call that\n    did not supply one properly -- see the module docstring.\n\n    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","sourceCodeStart":334,"sourceCodeEnd":370,"githubUrl":"https://github.com/HKUDS/Vibe-Trading/blob/80ffdda44c5c4db0dd84d70e051cca591cea67df/agent/src/quantlib/valuation/artifact.py#L334-L370","documentation":"_require_generated_at enforces that generated_at is a datetime.datetime explicitly supplied by the caller. The module deliberately never calls datetime.now() itself, so artifact timestamps are deterministic and reproducible; a non-datetime (string, date, float) is a TypeError.","triggerScenarios":"build_dcf_artifact(generated_at=\"2026-01-01\", ...); passing a datetime.date instead of datetime.datetime; passing a Unix timestamp float or None.","commonSituations":"Loading timestamps from JSON/YAML as strings; refactoring code that used date objects; test fixtures written with plain dates.","solutions":["Pass datetime.now(timezone.utc) (or a fixed aware datetime for reproducibility).","When parsing from text, use datetime.fromisoformat(value) and ensure tzinfo is set.","Use datetime.datetime, not datetime.date."],"exampleFix":"# before\nbuild_dcf_artifact(generated_at=\"2026-01-01\", ...)\n# after\nfrom datetime import datetime, timezone\nbuild_dcf_artifact(generated_at=datetime.now(timezone.utc), ...)","handlingStrategy":"type-guard","validationCode":"from datetime import datetime\nif not isinstance(generated_at, datetime):\n    raise TypeError(\"generated_at must be a datetime.datetime\")","typeGuard":"from datetime import datetime\ndef is_datetime(value) -> bool:\n    return isinstance(value, datetime)","tryCatchPattern":null,"preventionTips":["Use datetime.now(timezone.utc) at call sites; never strings.","When loading from JSON, parse timestamps with datetime.fromisoformat."],"tags":["python","datetime","type-validation","artifact"],"backgroundTag":"wrong-argument-type","analyzedSha":"80ffdda44c5c4db0dd84d70e051cca591cea67df","analyzedAt":"2026-08-28T12:46:38.989Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}