Skip to content

fix: Handle trailing bytes in dump keys#4630

Open
SharanRP wants to merge 1 commit intosourcenetwork:developfrom
SharanRP:fix/4573-invalid-cid-dump
Open

fix: Handle trailing bytes in dump keys#4630
SharanRP wants to merge 1 commit intosourcenetwork:developfrom
SharanRP:fix/4573-invalid-cid-dump

Conversation

@SharanRP
Copy link
Copy Markdown
Contributor

Relevant issue(s)

Resolves #4573

Description

Fixes the /debug/dump endpoint failure when chunk storage is enabled.

  • Replaced cid.Cast with cid.CidFromBytes in HumanReadableKey to tolerate trailing chunk metadata bytes in raw keys.
  • Corrected a copy-paste bug where case encStoreKey shadowed systemStoreKey.

Tasks

  • I made sure the code is well commented.
  • I made sure the pull request title adheres to the conventional commit style.

How has this been tested?

Verified with a reproduction script using cid.CidFromBytes on keys with trailing metadata. Ran internal datastore tests to ensure no regressions.

Tested on:

  • Linux

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 13, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 32698c55-36b0-4de6-9d53-54e82498ddaf

📥 Commits

Reviewing files that changed from the base of the PR and between 150204c and 28acbac.

📒 Files selected for processing (1)
  • internal/datastore/multi.go
📜 Recent review details
🔇 Additional comments (3)
internal/datastore/multi.go (3)

127-138: Correct fix for handling trailing bytes in block store keys.

Using cid.CidFromBytes instead of cid.Cast properly handles keys containing trailing chunk metadata bytes. The first return value (bytes consumed) is correctly discarded since we only need the parsed CID for the human-readable representation.

[approve_code_changes, request_verification]

go-cid CidFromBytes function signature and behavior

141-146: Consistent application of the CID parsing fix.

The same CidFromBytes pattern is correctly applied to the encryption store keys.


147-148: Correct case statement for systemStoreKey.

The switch now properly handles systemStoreKey ('s'). All six store key prefixes defined at lines 29-34 are now correctly handled in the switch statement.


📝 Walkthrough

Walkthrough

Replaced cid.Cast with cid.CidFromBytes in the HumanReadableKey function to handle blockstore keys containing trailing metadata bytes, and removed a redundant case statement for systemStoreKey.

Changes

Cohort / File(s) Summary
CID extraction refactor
internal/datastore/multi.go
Replaced cid.Cast with cid.CidFromBytes to parse CID from key bytes while handling trailing bytes; removed redundant systemStoreKey case header.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Assessment against linked issues

Objective Addressed Explanation
Fix cid.Cast() failing on blockstore keys with trailing bytes [#4573]
Remove duplicate/redundant case encStoreKey shadowing systemStoreKey [#4573]
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

You can customize the tone of the review comments and chat replies.

Configure the tone_instructions setting to customize the tone of the review comments and chat replies. For example, you can set the tone to Act like a strict teacher, Act like a pirate and more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dump endpoint fails with 'invalid cid: trailing bytes' on blockstore keys

1 participant