MemPalace/mempalace · error · ValueError

remote artifact {artifact['id']!r} failed hash verification

Error message

remote artifact {artifact['id']!r} failed hash verification (claimed {artifact['sha256'][:16]}..., computed {digest[:16]}...)

What it means

Error "remote artifact {artifact['id']!r} failed hash verification (claimed {artifact['sha256'][:16]}..., computed {digest[:16]}...)" thrown in MemPalace/mempalace.

Source

Thrown at mempalace/logstream.py:939

        artifact_id = _sanitize_routing(artifact_id, "artifact_id")
        with self._lock:
            conn = self._conn()
            row = conn.execute("SELECT 1 FROM artifacts WHERE id = ?", (artifact_id,)).fetchone()
        return row is not None

    def apply_remote_artifact(self, artifact: dict) -> bool:
        """Fold one remote artifact in, idempotently, verifying its hash.

        Content is verbatim; the sha256 must match or the artifact is
        rejected — a corrupt transfer must never enter the store.
        """
        for key in ("id", "kind", "sha256", "content", "created_by", "created_at"):
            if not artifact.get(key):
                raise ValueError(f"remote artifact is missing required field {key!r}")
        content = artifact["content"]
        digest = sha256(content.encode("utf-8")).hexdigest()
        if digest != artifact["sha256"]:
            raise ValueError(
                f"remote artifact {artifact['id']!r} failed hash verification "
                f"(claimed {artifact['sha256'][:16]}..., computed {digest[:16]}...)"
            )
        metadata_json = _sanitize_metadata(artifact.get("metadata"))
        with self._lock:
            conn = self._conn()
            with conn:
                dup = conn.execute(
                    "SELECT 1 FROM artifacts WHERE id = ?", (artifact["id"],)
                ).fetchone()
                if dup:
                    return False
                conn.execute(
                    "INSERT INTO artifacts (id, kind, sha256, size_bytes, content,"
                    " created_by, created_at, metadata_json, origin_replica)"
                    " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
                    (
                        artifact["id"],

View on GitHub (pinned to 06cb6987f0)

Solutions

  1. Re-fetch the artifact; if the hash still mismatches, treat the peer as untrusted and investigate corruption or tampering

When it happens

Trigger: Thrown at mempalace/logstream.py:939 when the library encounters an invalid state.

Common situations: Artifact bytes were corrupted in transit or the peer served tampered content.


AI-assisted analysis of MemPalace/mempalace@06cb6987f0 (2026-08-15). Data as JSON: /api/errors/023c5ba819725c63. Report an issue: GitHub.