router-for-me/CLIProxyAPI · error

line %d: invalid checksum entry

Error message

line %d: invalid checksum entry

What it means

ParseChecksums hit a non-comment, non-empty line in a plugin store checksums file that split into fewer than 2 whitespace-separated fields. The expected format is sha256sum-style 'HASH filename' per line; a single-token line means a truncated, hand-edited, or corrupt checksums file. Line numbers are 1-based and included in the message.

Source

Thrown at internal/pluginstore/checksum.go:19

package pluginstore

import (
	"crypto/sha256"
	"encoding/hex"
	"fmt"
	"strings"
)

func ParseChecksums(data []byte) (map[string]string, error) {
	out := map[string]string{}
	for lineNumber, rawLine := range strings.Split(string(data), "\n") {
		line := strings.TrimSpace(rawLine)
		if line == "" || strings.HasPrefix(line, "#") {
			continue
		}
		fields := strings.Fields(line)
		if len(fields) < 2 {
			return nil, fmt.Errorf("line %d: invalid checksum entry", lineNumber+1)
		}
		hash := strings.ToLower(strings.TrimSpace(fields[0]))
		if len(hash) != sha256.Size*2 {
			return nil, fmt.Errorf("line %d: invalid sha256 length", lineNumber+1)
		}
		if _, errDecode := hex.DecodeString(hash); errDecode != nil {
			return nil, fmt.Errorf("line %d: invalid sha256: %w", lineNumber+1, errDecode)
		}
		name := strings.TrimPrefix(strings.TrimSpace(fields[1]), "*")
		out[name] = hash
	}
	return out, nil
}

func VerifyChecksum(name string, data []byte, checksums map[string]string) error {
	expected := strings.ToLower(strings.TrimSpace(checksums[name]))
	if expected == "" {
		return fmt.Errorf("checksum for %s not found", name)

View on GitHub (pinned to 78f0c4079e)

Solutions

  1. Regenerate the checksums file in sha256sum format: sha256sum <files> > checksums.txt
  2. Inspect the named line for truncation or merge artifacts and fix it
  3. If the store publishes a different checksum format, convert it or fix the store tooling

Example fix

# before (line 3)
d41d8cd98f00b204e9800998ecf8427e

# after (line 3)
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855  plugin.wasm
Defensive patterns

Strategy: validation

Validate before calling

func checksumFileWellFormed(data []byte) error {
    for i, raw := range strings.Split(string(data), "\n") {
        line := strings.TrimSpace(raw)
        if line == "" || strings.HasPrefix(line, "#") { continue }
        if len(strings.Fields(line)) < 2 {
            return fmt.Errorf("line %d will fail ParseChecksums", i+1)
        }
    }
    return nil
}

Prevention

When it happens

Trigger: The downloaded checksums file contains a lone hash with no filename, a stray word, or a wrapped/broken line — e.g. 'd41d8cd9...' alone on line 3 — during plugin install/verify.

Common situations: Checksums file edited by hand and a line accidentally deleted in halves; file corrupted in transit or by CRLF conversion merging lines; a store publishing a different format (e.g. SHA1SUMS) that this parser rejects.

Related errors


AI-assisted analysis of router-for-me/CLIProxyAPI@78f0c4079e (2026-08-15). Data as JSON: /api/errors/b9d9338e69153ffd. Report an issue: GitHub.