{"record":{"id":"c3ab5e3337f8887d","repo":"666ghj/MiroFish","slug":"unsupported-reconstruction-method","errorCode":null,"errorMessage":"unsupported reconstruction method","messagePattern":"unsupported reconstruction method","errorType":"exception","errorClass":"StarHistoryError","httpStatus":null,"severity":"error","filePath":"scripts/star_history.py","lineNumber":386,"sourceCode":"    ):\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:\n        raise StarHistoryError(\"aggregate-only history cannot contain reconstructed dates\")\n\n    previous_day: date | None = None\n    previous_stars = 0\n    for index, raw_point in enumerate(daily):\n        if not isinstance(raw_point, dict):\n            raise StarHistoryError(\"reconstruction point must be an object\")\n        _expect_keys(raw_point, {\"date\", \"stars\"}, \"reconstruction point\")\n        raw_date = raw_point[\"date\"]\n        if not isinstance(raw_date, str):\n            raise StarHistoryError(\"reconstruction date must be a string\")","sourceCodeStart":368,"sourceCodeEnd":404,"githubUrl":"https://github.com/666ghj/MiroFish/blob/b5b53acc57189a4a42e44a23e149dc655c98fe82/scripts/star_history.py#L368-L404","documentation":"Raised by validate_state() when reconstruction['method'] is not one of the two supported values: 'current_stargazers_starred_at' or 'aggregate_snapshot_only'. The method names how the historical daily star counts were reconstructed, and downstream logic (notably the rule that aggregate_snapshot_only forbids daily entries) depends on it.","triggerScenarios":"validate_state(state) with reconstruction.method set to any other string (typo like 'current_stargazers_starredAt', a legacy value, or an empty string), or when the field was omitted and _expect_keys already passed because the value exists but is wrong.","commonSituations":"Renaming the method in a script version change without migrating old state files; hand-authoring a state file and guessing the method name; copy-pasting between projects that use different method identifiers.","solutions":["Set method to exactly 'current_stargazers_starred_at' or 'aggregate_snapshot_only'","If a schema migration happened, regenerate the state file with the current script version instead of reusing the old one","If writing a new producer of this state, align the enum with the validator's set"],"exampleFix":"// before\n\"method\": \"current_stargazers\"\n// after\n\"method\": \"current_stargazers_starred_at\"","handlingStrategy":"validation","validationCode":"METHODS = {\"current_stargazers_starred_at\", \"aggregate_snapshot_only\"}\nif state[\"reconstruction\"][\"method\"] not in METHODS:\n    raise ValueError(\"unsupported reconstruction method\")","typeGuard":"SUPPORTED_METHODS = {\"current_stargazers_starred_at\", \"aggregate_snapshot_only\"}\n\ndef is_supported_method(value) -> bool:\n    return value in SUPPORTED_METHODS","tryCatchPattern":"try:\n    validate_state(state)\nexcept StarHistoryError as exc:\n    if \"unsupported reconstruction method\" in str(exc):\n        state[\"reconstruction\"][\"method\"] = None  # force regeneration\n","preventionTips":["Define the method enum in one shared constant used by both writer and validator","Add a unit test that round-trips every supported method through validate_state","Refuse to load state files from script versions you cannot identify"],"tags":["validation","enum","state-file"],"backgroundTag":null,"analyzedSha":"b5b53acc57189a4a42e44a23e149dc655c98fe82","analyzedAt":"2026-08-14T22:29:33.146Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}