666ghj/MiroFish · error · StarHistoryError

unsupported reconstruction method

Error message

unsupported reconstruction method

What it means

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.

Source

Thrown at scripts/star_history.py:386

    ):
        raise StarHistoryError(
            f"history interval must be exactly {INTERVAL_DAYS} days"
        )

    reconstruction = state["reconstruction"]
    if not isinstance(reconstruction, dict):
        raise StarHistoryError("reconstruction must be an object")
    _expect_keys(
        reconstruction,
        {"method", "generated_at", "daily"},
        "reconstruction",
    )
    reconstruction_method = reconstruction["method"]
    if reconstruction_method not in {
        "current_stargazers_starred_at",
        "aggregate_snapshot_only",
    }:
        raise StarHistoryError("unsupported reconstruction method")
    generated_at = _parse_state_timestamp(
        reconstruction["generated_at"], "reconstruction.generated_at"
    )
    daily = reconstruction["daily"]
    if not isinstance(daily, list):
        raise StarHistoryError("reconstruction.daily must be a list")
    if reconstruction_method == "aggregate_snapshot_only" and daily:
        raise StarHistoryError("aggregate-only history cannot contain reconstructed dates")

    previous_day: date | None = None
    previous_stars = 0
    for index, raw_point in enumerate(daily):
        if not isinstance(raw_point, dict):
            raise StarHistoryError("reconstruction point must be an object")
        _expect_keys(raw_point, {"date", "stars"}, "reconstruction point")
        raw_date = raw_point["date"]
        if not isinstance(raw_date, str):
            raise StarHistoryError("reconstruction date must be a string")

View on GitHub (pinned to b5b53acc57)

Solutions

  1. Set method to exactly 'current_stargazers_starred_at' or 'aggregate_snapshot_only'
  2. If a schema migration happened, regenerate the state file with the current script version instead of reusing the old one
  3. If writing a new producer of this state, align the enum with the validator's set

Example fix

// before
"method": "current_stargazers"
// after
"method": "current_stargazers_starred_at"
Defensive patterns

Strategy: validation

Validate before calling

METHODS = {"current_stargazers_starred_at", "aggregate_snapshot_only"}
if state["reconstruction"]["method"] not in METHODS:
    raise ValueError("unsupported reconstruction method")

Type guard

SUPPORTED_METHODS = {"current_stargazers_starred_at", "aggregate_snapshot_only"}

def is_supported_method(value) -> bool:
    return value in SUPPORTED_METHODS

Try / catch

try:
    validate_state(state)
except StarHistoryError as exc:
    if "unsupported reconstruction method" in str(exc):
        state["reconstruction"]["method"] = None  # force regeneration

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of 666ghj/MiroFish@b5b53acc57 (2026-08-14). Data as JSON: /api/errors/c3ab5e3337f8887d. Report an issue: GitHub.