{"record":{"id":"c0a54b10b93a3fe7","repo":"jdx/mise","slug":"invalid-checkpoint-reference-spec","errorCode":null,"errorMessage":"invalid checkpoint reference {spec:?}","messagePattern":"invalid checkpoint reference (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/history/store.rs","lineNumber":918,"sourceCode":"                )\n            });\n    }\n    let prefix = if let Some(prefix) = spec.strip_prefix(\"commit:\") {\n        prefix\n    } else if !spec.is_empty() && spec.bytes().all(|byte| byte.is_ascii_digit()) {\n        let id = spec.parse::<u64>().map_err(|_| {\n            eyre!(\"invalid checkpoint ID {spec:?}; use commit:<sha> for a numeric commit hash\")\n        })?;\n        return entries\n            .iter()\n            .find(|entry| entry.id == id)\n            .map(|entry| entry.id)\n            .ok_or_else(|| eyre!(\"no history checkpoint matches {spec:?}\"));\n    } else {\n        spec\n    };\n    if prefix.is_empty() {\n        bail!(\"invalid checkpoint reference {spec:?}\");\n    }\n    let matches: Vec<&Entry> = entries\n        .iter()\n        .filter(|entry| entry.checkpoint.uuid.starts_with(prefix))\n        .collect();\n    match matches.as_slice() {\n        [one] => Ok(one.id),\n        [] => bail!(\"no history checkpoint matches {spec:?}\"),\n        _ => bail!(\"{spec:?} matches more than one checkpoint; use a longer prefix\"),\n    }\n}\n\npub(crate) fn now_rfc3339() -> String {\n    chrono::Utc::now().to_rfc3339_opts(chrono::SecondsFormat::Millis, true)\n}\n\npub(crate) fn new_uuid() -> String {\n    uuid::Uuid::now_v7().to_string()","sourceCodeStart":900,"sourceCodeEnd":936,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/system/history/store.rs#L900-L936","documentation":"Checkpoint references in dotfile history can be a UUID prefix or an ID. After resolving any non-empty spec through the entry list, the code checks the resulting prefix; if it is empty, the spec cannot name any checkpoint and the error reports the original spec verbatim. This guards against empty or effectively-empty references reaching the prefix-matching stage.","triggerScenarios":"Passing an empty string or a spec that resolves to an empty prefix (e.g. `\"\"`, or a spec form that strips to nothing) to the checkpoint-lookup API (`mise dot` restore/checkout with a blank PATH-ish argument).","commonSituations":"A shell variable holding the checkpoint ID is unset/empty (`mise dot restore \"$CHK\"` with `CHK=`); copying a reference that trimmed to nothing; a script parameter defaulting to empty.","solutions":["Check that the shell variable or argument actually contains the checkpoint ID: `echo \"${CHK:?empty}\"`.","List valid checkpoints with `mise dot log` and copy a full (or long) UUID prefix.","Quote arguments so whitespace doesn't split or empty them: `mise dot restore \"$1\"`.","Pass the full UUID instead of a prefix to eliminate ambiguity."],"exampleFix":"// before\nlet spec = env::var(\"CHK\").unwrap_or_default(); // may be empty\n// after\nlet spec = env::var(\"CHK\").expect(\"CHK must hold a checkpoint id\");\nassert!(!spec.is_empty(), \"invalid checkpoint reference {spec:?}\");","handlingStrategy":"validation","validationCode":"let spec = std::env::var(\"CHK\")?;\nif spec.trim().is_empty() {\n    eprintln!(\"CHK is empty; provide a checkpoint id from `mise dot log`\");\n}","typeGuard":"fn non_empty(s: &str) -> Option<&str> {\n    let t = s.trim(); if t.is_empty() { None } else { Some(t) }\n}","tryCatchPattern":"match resolve_checkpoint(spec) {\n    Ok(id) => use(id),\n    Err(e) if e.to_string().contains(\"invalid checkpoint reference\") => {\n        eprintln!(\"empty or malformed reference; run `mise dot log` for valid ids\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Guard shell variables: `${CHK:?checkpoint id required}`","Quote CLI arguments so they can't collapse to empty","Verify variables hold values before passing them as specs"],"tags":["cli","checkpoint","empty-argument","dotfiles"],"backgroundTag":"empty-required-field","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}