Skip to content

bm_read omits checksum on full reads of binary files #2150

Backlog

Description

@phernandez

Problem

A full bm_read of a non-Markdown binary file (a PDF or an image) returns the file content without a checksum field. Markdown notes and text files include it. A customer's backup job checks each file against Basic Memory's stored checksum. Because of this, it reads the PDF's checksum as empty (length 0), and the check fails on every run, even though the file is intact.

The checksum does exist. bm_read(..., include_content=false) returns it for any file type, and the entity row has it.

Where

src/basic_memory/mcp/tools/read.py, in the # --- Files that are not Markdown notes --- branch:

  • _present_file(...) returns image content or document.to_resource_content(...) for binaries, with no metadata attached.
  • The text-file path returns a dict through target.paths.note(...), and the metadata-only path includes "checksum": entity.db_checksum.

The JSON output of bm tool read --json for a binary therefore has no checksum to report.

Second issue: what the checksum means

In Cloud, db_checksum is the storage ETag: 32 hex characters, which for single-part uploads is the MD5 of the bytes. Locally it is SHA-256 (64 hex characters). Projects can even mix both (one production workspace has 32- and 64-character values side by side). Callers have no way to tell which algorithm a value uses, so comparing it with a local SHA-256 fails even when the file is intact.

Proposed

  1. Include checksum (and content_type, file_path) in the JSON result of a full binary read, matching text files and notes.
  2. Document what the checksum is, or return it with its algorithm (for example checksum_algorithm: "md5-etag" | "sha256"), so backup and verification tools can compare correctly.

Done when

  • bm tool read --cloud --json on a PDF returns a non-empty checksum.
  • The docs (or the response itself) say which hash the checksum is.
  • There is a test for a full binary read in JSON output that asserts the checksum is present.

Activity

  1. added
    bug
    on Nov 25, 2026
  2. claude commented on Nov 25, 2026

    @claude
    Contributor

    Claude finished @phernandez's task in 13s —— View job


    Triage

    • Type: Bug (labeled bug, cloud)
    • Component: MCP tools (read.py, non-Markdown branch) and CLI JSON output. The checksum semantics concern Cloud, since the storage ETag is MD5 there and SHA-256 locally.
    • Priority: Medium-High. A customer's backup verification fails on every run, but the data is intact and there is a workaround: include_content=false returns the checksum.
    • Complexity: Simple to Medium.
      • Part 1: add checksum, content_type and file_path to the binary read result. This is a small change plus a test.
      • Part 2: either document the algorithm or return a checksum_algorithm field. This needs a design decision, because Cloud can mix 32-character MD5 ETags and 64-character SHA-256 values in the same project. Inferring the algorithm from the checksum length is fragile, so it would be better to record the algorithm at write time.

    Duplicates: I searched for existing issues on checksums in binary reads and found none.

    Notes: The issue is clear and includes a location, a proposal and acceptance criteria. I did not investigate further or implement anything, because this was triage only.

  3. added
    cloud
    on Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugcloud

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions