fix: prevent nil pointer dereference when admin_nodeInfo omits difficulty#153
Open
MysticRyuujin wants to merge 2 commits intoethpandaops:mainfrom
Open
fix: prevent nil pointer dereference when admin_nodeInfo omits difficulty#153MysticRyuujin wants to merge 2 commits intoethpandaops:mainfrom
MysticRyuujin wants to merge 2 commits intoethpandaops:mainfrom
Conversation
…ulty Post-merge Geth and other clients may omit the difficulty field from admin_nodeInfo responses. The EthProtocol.UnmarshalJSON was dereferencing objMap["difficulty"] without checking for nil, causing a panic. Add nil check before accessing difficulty; when missing, unmarshal the rest of the struct and leave Difficulty as nil. Made-with: Cursor
Made-with: Cursor
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.
Problem
The exporter panics with a nil pointer dereference when calling
admin_nodeInfoagainst Geth (and potentially other clients) that omit thedifficultyfield from the response. This commonly occurs with post-merge clients where difficulty is no longer relevant.Root Cause
In
EthProtocol.UnmarshalJSON, the code dereferencesobjMap["difficulty"]without checking if the key exists. Whendifficultyis missing from the JSON,objMap["difficulty"]is nil and*objMap["difficulty"]causes the panic.Solution
objMap["difficulty"]Difficultyas nil