{"record":{"id":"dadda321c8dc0e5b","repo":"666ghj/MiroFish","slug":"reconstruction-must-be-an-object","errorCode":null,"errorMessage":"reconstruction must be an object","messagePattern":"reconstruction must be an object","errorType":"exception","errorClass":"StarHistoryError","httpStatus":null,"severity":"error","filePath":"scripts/star_history.py","lineNumber":375,"sourceCode":"        \"history state\",\n    )\n    if state[\"schema_version\"] != 1 or type(state[\"schema_version\"]) is not int:\n        raise StarHistoryError(\"unsupported history schema_version\")\n    if state[\"repository\"] != REPOSITORY:\n        raise StarHistoryError(\"history repository does not match configured repository\")\n    if state[\"timezone\"] != \"UTC\":\n        raise StarHistoryError(\"history timezone must be UTC\")\n    if (\n        state[\"ongoing_interval_days\"] != INTERVAL_DAYS\n        or type(state[\"ongoing_interval_days\"]) is not int\n    ):\n        raise StarHistoryError(\n            f\"history interval must be exactly {INTERVAL_DAYS} days\"\n        )\n\n    reconstruction = state[\"reconstruction\"]\n    if not isinstance(reconstruction, dict):\n        raise StarHistoryError(\"reconstruction must be an object\")\n    _expect_keys(\n        reconstruction,\n        {\"method\", \"generated_at\", \"daily\"},\n        \"reconstruction\",\n    )\n    reconstruction_method = reconstruction[\"method\"]\n    if reconstruction_method not in {\n        \"current_stargazers_starred_at\",\n        \"aggregate_snapshot_only\",\n    }:\n        raise StarHistoryError(\"unsupported reconstruction method\")\n    generated_at = _parse_state_timestamp(\n        reconstruction[\"generated_at\"], \"reconstruction.generated_at\"\n    )\n    daily = reconstruction[\"daily\"]\n    if not isinstance(daily, list):\n        raise StarHistoryError(\"reconstruction.daily must be a list\")\n    if reconstruction_method == \"aggregate_snapshot_only\" and daily:","sourceCodeStart":357,"sourceCodeEnd":393,"githubUrl":"https://github.com/666ghj/MiroFish/blob/b5b53acc57189a4a42e44a23e149dc655c98fe82/scripts/star_history.py#L357-L393","documentation":"Raised by validate_state() in scripts/star_history.py when the 'reconstruction' field of the star-history JSON state file is not a JSON object (dict). The validator requires the whole state document to match an exact schema, and reconstruction must be a dict with exactly the keys 'method', 'generated_at', and 'daily'. This error means the shape is fundamentally wrong before any field-level checks run.","triggerScenarios":"Calling validate_state(state) or canonical_state_bytes(state) (which calls validate_state internally) on a state dict where state['reconstruction'] is a list, string, number, null, or is missing-adjacent (e.g. hand-edited state file where reconstruction was replaced by an array of points).","commonSituations":"Hand-editing the state JSON and replacing the reconstruction object with a bare array of {date, stars} points; consuming a state file produced by a different/older version of the script with a different schema; deserializing YAML/JSON where the nesting level was flattened by mistake.","solutions":["Restore 'reconstruction' to a JSON object: {\"method\": ..., \"generated_at\": ..., \"daily\": [...]}","If the file was hand-edited, re-run the generation step instead of editing state manually","Check schema_version is 1 and the file matches the current script version's expected layout"],"exampleFix":"// before\n\"reconstruction\": [{\"date\": \"2024-01-01\", \"stars\": 10}]\n// after\n\"reconstruction\": {\n  \"method\": \"current_stargazers_starred_at\",\n  \"generated_at\": \"2024-01-02T00:00:00Z\",\n  \"daily\": [{\"date\": \"2024-01-01\", \"stars\": 10}]\n}","handlingStrategy":"validation","validationCode":"import json\nstate = json.loads(state_text)\nrec = state.get(\"reconstruction\")\nassert isinstance(rec, dict), \"reconstruction must be an object\"","typeGuard":"def is_reconstruction_object(value) -> bool:\n    return isinstance(value, dict)","tryCatchPattern":"try:\n    validate_state(state)\nexcept StarHistoryError as exc:\n    if \"reconstruction must be an object\" in str(exc):\n        # regenerate or reject the state file\n        ...","preventionTips":["Only produce state files via the script's canonical writer (canonical_state_bytes)","Never hand-edit the state JSON; regenerate instead","Treat any externally received state file as untrusted and validate before use"],"tags":["validation","json","state-file"],"backgroundTag":null,"analyzedSha":"b5b53acc57189a4a42e44a23e149dc655c98fe82","analyzedAt":"2026-08-14T22:29:33.146Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}