Skip to content

Hardcoded format version list in persistence error message #25

@Liorrr

Description

@Liorrr

Source

Found by Greptile review on PR #20 (merged).

Issue

The error message in crates/shrimpk-memory/src/persistence.rs (line 493-494) contains a hardcoded version list:

"Unsupported format version: {} (supported: 1, 2). \
 If your data was written by a newer ShrimPK version, update your binary.",
version_byte

The "supported: 1, 2" string is manually maintained. When a future v3 format is added, this string will need to be updated manually — easy to forget, leading to a confusing error that lists v2 as the latest when v3 already exists.

Suggested Fix

Derive the supported version list from constants:

const FORMAT_VERSION: u32 = 2;
const FORMAT_VERSION_LEGACY: u32 = 1;

// In error message:
format!(
    "Unsupported format version: {} (supported: {}-{}). ...",
    version_byte, FORMAT_VERSION_LEGACY, FORMAT_VERSION
)

Or maintain an array SUPPORTED_VERSIONS: &[u32] = &[1, 2] and format from that.

Priority

P2 — Non-blocking style/future-proofing. Current code is correct for v1/v2.

Labels

enhancement, persistence

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions