fix(store): return the error from indexEventByHash in IndexEvent - #563
Open
0xrlawrence wants to merge 1 commit into
Open
fix(store): return the error from indexEventByHash in IndexEvent#5630xrlawrence wants to merge 1 commit into
0xrlawrence wants to merge 1 commit into
Conversation
IndexEvent assigned the error from indexEventByHash to err and then
overwrote it on the next call without ever checking it:
hashKey, err := t.indexEventByHash(e)
heightAndIndexKey := t.eventHeightAndIndexKey(...)
if err = t.indexEventByHeightAndIndex(...); err != nil {
If the primary hash index write failed, the failure was discarded and the
function carried on writing the height, chainId and address indexes
pointing at a hashKey that was never persisted, leaving the indexer with
dangling secondary index entries and reporting success.
Check the error before it is reassigned. staticcheck flagged this as
SA4006.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
IndexEventassigned the error fromindexEventByHashand then overwrote it on the next call without ever checking it:If the primary hash index write failed, the failure was silently discarded. The function then carried on writing the height, chainId and address indexes, all pointing at a
hashKeythat was never persisted — leaving dangling secondary index entries and reporting success to the caller.staticcheck flagged this as SA4006.
Changes Made
indexEventByHashbefore it is reassigned, and return early.Testing
go build ./...go test ./store/passesstore/indexer.go🤖 Generated with Claude Code