henrygd/beszel · error

failed to calculate release checksum: %w

Error message

failed to calculate release checksum: %w

What it means

After opening the file, the library streams it into a sha256 hash via io.Copy. If reading fails mid-stream — disk I/O error, file truncated/removed while reading — the read error is wrapped with this message. This is about failing to compute the checksum, not a mismatch.

Source

Thrown at internal/ghupdate/checksum.go:35

	}
	if !strings.EqualFold(algorithm, "sha256") {
		return fmt.Errorf("unsupported release digest algorithm %q", algorithm)
	}

	expected, err := hex.DecodeString(expectedHex)
	if err != nil || len(expected) != sha256.Size {
		return fmt.Errorf("invalid SHA-256 release digest %q", digest)
	}

	file, err := os.Open(path)
	if err != nil {
		return fmt.Errorf("failed to open release for checksum verification: %w", err)
	}
	defer file.Close()

	hash := sha256.New()
	if _, err := io.Copy(hash, file); err != nil {
		return fmt.Errorf("failed to calculate release checksum: %w", err)
	}
	actual := hash.Sum(nil)
	if !bytes.Equal(actual, expected) {
		return fmt.Errorf("release checksum mismatch: expected %s, got %s", expectedHex, hex.EncodeToString(actual))
	}

	return nil
}

View on GitHub (pinned to b38fb7dafa)

Solutions

  1. Re-run the update; if the temp dir is on unstable storage, set Config.DataDir to a local reliable path.
  2. Check `dmesg`/system logs for disk I/O errors and run fsck or replace failing hardware.
  3. Ensure nothing concurrently deletes or truncates files in DataDir while the updater runs.
  4. Verify free disk space with `df -h` and the health of the mount hosting DataDir.

Example fix

// before
Update(ghupdate.Config{DataDir: "/mnt/nfs/shared"}) // flaky NFS reads
// after
Update(ghupdate.Config{DataDir: "/var/lib/beszel"}) // local disk
Defensive patterns

Strategy: retry

Validate before calling

if fi, err := os.Stat(cfg.DataDir); err == nil {
    if st, err := os.Statfs(cfg.DataDir); err == nil && st.Bavail == 0 {
        return errors.New("DataDir filesystem is full; free space before updating")
    }
}

Try / catch

var updated bool
var lastErr error
for i := 0; i < 3; i++ {
    updated, lastErr = ghupdate.Update(cfg)
    if lastErr == nil || !strings.Contains(lastErr.Error(), "failed to calculate release checksum") {
        break
    }
    time.Sleep(time.Second) // transient I/O error; retry
}

Prevention

When it happens

Trigger: ghupdate.Update -> update -> verifyAssetChecksum when io.Copy(hash, file) returns an error: hardware/disk I/O failure, file deleted or truncated by another process during hashing, or an fs error caused by a failing mount.

Common situations: Failing or full disks; network filesystems (NFS/CIFS) dropping the file mid-read; concurrent cleanup of the temp release directory; corrupted filesystem after a crash.

Related errors


AI-assisted analysis of henrygd/beszel@b38fb7dafa (2026-08-31). Data as JSON: /api/errors/4997dd502a799bbf. Report an issue: GitHub.