denisidoro/navi · error · anyhow

Incorrect hash

Error message

Incorrect hash

What it means

Returned by `read` in src/deser/raycast.rs when deserializing an item (a Raycast-style snippet) whose recomputed content hash does not match the expected hash stored alongside it. This guards against corrupted or hand-edited serialized data: the payload changed since the hash was written, so the library refuses to return untrusted data.

Source

Thrown at src/deser/raycast.rs:47

    let icon = if icon_str.is_empty() {
        None
    } else {
        Some(icon_str.into())
    };

    let item = Item {
        tags,
        comment,
        icon,
        snippet,
        ..Default::default()
    };

    if item.hash() != hash {
        dbg!(&item.hash());
        dbg!(hash);
        Err(anyhow!("Incorrect hash"))
    } else {
        Ok(item)
    }
}

View on GitHub (pinned to f7330b9ad5)

Solutions

  1. Regenerate or re-export the data so the stored hash is recomputed over the current content
  2. Restore the file from a backup made before it was modified
  3. Recreate the item through the tool itself instead of editing the storage file directly
  4. If a version upgrade changed the hash scheme, re-run any provided migration or delete the stale cache/data so it is rebuilt

Example fix

// before: hand-edited file fails hash check
{
  "name": "my snippet",
  "text": "edited content",
  "hash": "hash_of_original_content"
}
// after: rebuild the entry via the tool (or recompute)
{
  "name": "my snippet",
  "text": "edited content",
  "hash": "hash_of_edited_content"
}
Defensive patterns

Strategy: validation

Validate before calling

// compute the same hash over the raw content before calling read
let expected = hash_content(&raw_item);
if expected != stored_hash {
    eprintln!("stale/corrupted entry: rebuild or restore before reading");
}

Prevention

When it happens

Trigger: Calling the deserialization/read entry point on a file or record where `item.hash()` differs from the expected `hash` value — typically after the item's content was modified out-of-band or the storage format/version changed without re-hashing.

Common situations: Users manually editing snippet/config files managed by the tool; a version upgrade changing hashing of fields; truncated or corrupted files after a crash or sync conflict; copying data files between machines with different content encodings.


AI-assisted analysis of denisidoro/navi@f7330b9ad5 (2026-09-03). Data as JSON: /api/errors/96af20d5f7c502ac. Report an issue: GitHub.