-
Notifications
You must be signed in to change notification settings - Fork 2
fix: don't try to decode empty resource data in covenants #458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📝 WalkthroughWalkthroughDecoding of resource data in NewRegisterCovenantFromGeneric and NewUpdateCovenantFromGeneric is now conditional: the code only attempts to decode and assign ResourceData when gc.Items[2] has non-zero length. DomainResourceData.decode now wraps errors for version reads, record-type reads, and record decoding; it also uses a loop label and breaks out when encountering an unknown record type instead of returning an error. Public APIs and exported declarations are unchanged. Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Pre-merge checks and finishing touches✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (3)
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. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
handshake/covenant.go (1)
396-402: LGTM! Fixes the Update covenant EOF panic.The conditional check prevents the EOF panic mentioned in issue #457. The error wrapping provides helpful context if decoding fails.
Minor inconsistency:
NewRegisterCovenantFromGeneric(lines 358-364) doesn't wrap its decode error, while this function does. Consider adding similar error wrapping to the Register covenant for consistency.Apply this diff to add consistent error wrapping to
NewRegisterCovenantFromGeneric:if len(gc.Items[2]) > 0 { tmpData, err := NewDomainResourceDataFromBytes(gc.Items[2]) if err != nil { - return nil, err + return nil, fmt.Errorf("decode domain resource data: %w", err) } ret.ResourceData = *tmpData }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
handshake/covenant.go(2 hunks)handshake/domain.go(3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
handshake/covenant.go (1)
handshake/domain.go (1)
NewDomainResourceDataFromBytes(60-66)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: cubic · AI code reviewer
- GitHub Check: Analyze (go)
🔇 Additional comments (2)
handshake/domain.go (1)
73-73: LGTM! Error wrapping improves diagnostics.The added error wrapping provides valuable context about which decoding step failed (version read, record type read, or record decode), making it easier to diagnose issues like the EOF panic described in #457.
Also applies to: 84-84, 107-107
handshake/covenant.go (1)
358-364: LGTM! Prevents EOF panic on empty resource data.The conditional check prevents attempting to decode empty resource data, which was causing the EOF panic described in issue #457. When
gc.Items[2]is empty,ResourceDataremains as its zero value, which is appropriate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No issues found across 2 files
Fixes #457 Signed-off-by: Aurora Gaffney <aurora@blinklabs.io>
d5a227f to
66e5805
Compare
Fixes #457
Summary by cubic
Prevents decoding empty resource data in Handshake register/update covenants to avoid errors when resource bytes are missing. Also adds clearer error messages when decoding domain resource data.
Written for commit 66e5805. Summary will update automatically on new commits.
Summary by CodeRabbit
Bug Fixes
Chores
✏️ Tip: You can customize this high-level summary in your review settings.