Skip to content

[#376] Fall back to provided content on IPFS hash mismatch#377

Merged
realproject7 merged 1 commit intomainfrom
task/376-ipfs-hash-fallback
Mar 20, 2026
Merged

[#376] Fall back to provided content on IPFS hash mismatch#377
realproject7 merged 1 commit intomainfrom
task/376-ipfs-hash-fallback

Conversation

@realproject7
Copy link
Copy Markdown
Owner

Summary

  • Storyline and plot indexer routes now try fallback content when IPFS content's hash doesn't match the on-chain hash
  • Previously fallback was only used on IPFS fetch failure — now also used on hash mismatch
  • Both paths still validate the content hash before insert

Test plan

  • POST with valid tx hash + correct fallback content → 200 (even when IPFS returns wrong content)
  • POST with valid tx hash, no content, IPFS hash matches → 200 (existing behavior preserved)
  • POST with valid tx hash, wrong fallback content, IPFS hash mismatches → 400 (both sources fail)

Fixes #376

🤖 Generated with Claude Code

Previously, fallback content was only used when IPFS fetch failed.
If IPFS returned content whose hash didn't match the on-chain hash
(e.g. dummy CIDs pointing to unrelated IPFS content), the indexer
returned 400 with no way to override.

Now both storyline and plot routes:
1. Try IPFS content first, verify hash
2. If hash mismatches, try fallback content and verify its hash
3. Only fail if neither source provides hash-matching content

Fixes #376

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

T2b Review — APPROVED

Clean fix. Both routes now follow the same pattern:

  1. Try IPFS → verify hash → accept if match
  2. On mismatch or fetch failure → try fallback content → verify hash → accept if match
  3. Both fail → 400 with clear error message

Hash validation is preserved on both paths — fallback content is never blindly trusted. Error message updated to clarify both sources were tried. LGTM.

Copy link
Copy Markdown
Collaborator

@project7-interns project7-interns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: APPROVE

Summary

The route logic now correctly falls back to provided content when IPFS content exists but hashes to the wrong value, while still requiring the fallback content to match the on-chain hash before insert. That matches the issue scope and preserves the intended validation boundary.

Findings

  • None.

Decision

Approving because the hash-mismatch fallback behavior is implemented in the right place and the change is narrowly scoped. Note: GitHub lint-and-typecheck was still pending at review time, so merge should still wait for that check to finish green.

@realproject7 realproject7 merged commit e5d8eef into main Mar 20, 2026
1 check passed
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.

[Bug] Indexer Should Fall Back When IPFS Content Hash Mismatches On-Chain Hash

2 participants