Skip to content

execution/abi: return errors for invalid ParseTopics output#20800

Open
JayeTurn wants to merge 1 commit intoerigontech:mainfrom
JayeTurn:fix/parse-topics-invalid-output
Open

execution/abi: return errors for invalid ParseTopics output#20800
JayeTurn wants to merge 1 commit intoerigontech:mainfrom
JayeTurn:fix/parse-topics-invalid-output

Conversation

@JayeTurn
Copy link
Copy Markdown
Contributor

Summary

  • Validate the destination passed to ParseTopics before setting reflected fields.
  • Return ABI errors when indexed event fields cannot be mapped to a writable, assignable struct field.
  • Add regression coverage for missing fields, type mismatches, and non-pointer outputs.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens execution/abi topic parsing by preventing reflection panics and returning actionable ABI errors when ParseTopics can’t write decoded indexed fields into the provided destination, plus adding regression tests for invalid outputs.

Changes:

  • Add destination validation and assignability checks to ParseTopics, returning errors instead of panicking on bad outputs.
  • Update the internal parseTopicWithSetter to propagate setter errors.
  • Add regression tests covering missing fields, type mismatches, and non-pointer outputs.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
execution/abi/topics.go Adds error-returning setter plumbing and validates/refuses invalid ParseTopics destinations/field mappings.
execution/abi/topics_test.go Adds TestParseTopicsInvalidOutput to lock in error behavior for invalid outputs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread execution/abi/topics.go
Comment on lines 149 to 153
return parseTopicWithSetter(fields, topics,
func(arg Argument, reconstr any) {
func(arg Argument, reconstr any) error {
out[arg.Name] = reconstr
return nil
})
Comment thread execution/abi/topics.go
Comment on lines +122 to +126
func(arg Argument, reconstr any) error {
value := reflect.ValueOf(out)
if value.Kind() != reflect.Pointer || value.IsNil() {
return fmt.Errorf("abi: cannot unmarshal indexed event fields into %T", out)
}
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.

3 participants