Skip to content

flow.NewPayload to reject nil elements in Guarantees, Seals etc - #8667

Open
zhangchiqing wants to merge 1 commit into
masterfrom
leo/fix-new-payload-nil-element-validation
Open

flow.NewPayload to reject nil elements in Guarantees, Seals etc#8667
zhangchiqing wants to merge 1 commit into
masterfrom
leo/fix-new-payload-nil-element-validation

Conversation

@zhangchiqing

@zhangchiqing zhangchiqing commented Aug 26, 2026

Copy link
Copy Markdown
Member

Problem

flow.NewPayload (model/flow/payload.go) validates only ProtocolStateID but does not check the elements of the Guarantees, Seals, Receipts, and Results slices for nil. A CBOR-decoded block payload with a null array element yields a nil pointer that passes construction and propagates into a trusted *flow.Payload.

Fix

Added nil-element validation for all four slices in NewPayload, mirroring the existing pattern in NewCollection. Since NewProposal calls NewBlock, which calls NewPayload, fixing the constructor covers all ingestion paths.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Summary by CodeRabbit

  • Bug Fixes
    • Payload validation now reports clear, indexed errors when invalid empty entries are included in guarantees, seals, receipts, or results.
    • Improved handling of missing protocol state identifiers during payload validation.

@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 73e2eb83-2c1e-426f-886d-4b5439701321

📥 Commits

Reviewing files that changed from the base of the PR and between dd885b2 and 6533e6f.

📒 Files selected for processing (2)
  • model/flow/payload.go
  • model/flow/payload_test.go

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

NewPayload now rejects nil elements in guarantees, seals, receipts, and results. Tests verify nil results, indexed error messages, and the renamed zero ProtocolStateID case.

Changes

Payload validation

Layer / File(s) Summary
Reject nil payload entries
model/flow/payload.go, model/flow/payload_test.go
NewPayload validates all four collections and returns index-specific errors for nil entries. Tests cover each collection and update the zero ProtocolStateID subtest name.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: 🔵 Low · up to 6533e

The PR correctly rejects nil elements in payload collections, but the new validation should report expected invalid input through ordinary constructor errors rather than an unrecoverable failure path. The change is otherwise localized and mergeable with explicit owner follow-up.

Suggested reviewers: alexhentschel, j1010001, janezpodhostnik

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: flow.NewPayload rejects nil elements in the Guarantees, Seals, and related collections.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch leo/fix-new-payload-nil-element-validation

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@zhangchiqing
zhangchiqing force-pushed the leo/fix-new-payload-nil-element-validation branch from 22d8939 to 6533e6f Compare August 26, 2026 18:11
@zhangchiqing zhangchiqing changed the title flow.NewPayload does not reject nil elements in Guarantees, Seals etc flow.NewPayload to reject nil elements in Guarantees, Seals etc Aug 26, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@zhangchiqing
zhangchiqing marked this pull request as ready for review August 26, 2026 18:45
@zhangchiqing
zhangchiqing requested a review from a team as a code owner August 26, 2026 18:45
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.

2 participants