graphql: add nil check in block resolver (#33225)
Some checks failed
/ Keeper Build (push) Has been cancelled
/ Windows Build (push) Has been cancelled
/ Docker Image (push) Has been cancelled
/ Linux Build (push) Has been cancelled
/ Linux Build (arm) (push) Has been cancelled

Add nil checks for header and block in Block resolver methods to prevent
panic when querying non-existent blocks.
This commit is contained in:
Rizky Ikwan 2025-12-19 12:29:41 +01:00 committed by GitHub
parent bf141fbfb1
commit 2e5cd21edf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -707,6 +707,9 @@ func (b *Block) resolveHeader(ctx context.Context) (*types.Header, error) {
if err != nil {
return nil, err
}
if b.header == nil {
return nil, nil
}
if b.hash == (common.Hash{}) {
b.hash = b.header.Hash()
}