Skip to content

fix: guard protobuf oneof/union reflection on nil oneof values#910

Open
fallintoplace wants to merge 3 commits into
apache:mainfrom
fallintoplace:fix-protobuf-oneof-nil-safe
Open

fix: guard protobuf oneof/union reflection on nil oneof values#910
fallintoplace wants to merge 3 commits into
apache:mainfrom
fallintoplace:fix-protobuf-oneof-nil-safe

Conversation

@fallintoplace

Copy link
Copy Markdown
Contributor

Summary

  • Harden protobuf union/oneof dereference logic to avoid panics on nil/invalid reflection values.
  • In protobufUnionReflection.isThisOne, dereference pointers/interfaces only when non-nil and return false for invalid/empty values.
  • Harden ProtobufMessageReflection.getFieldByName when dereferencing pointer/interface fields to avoid zero-value reflection from nil pointers/interfaces.
  • Add regression coverage for oneof union behavior with unset, nil-pointer, and valid oneof values (TestUnionReflectionHandlesUnsetAndNilOneofValues).

Testing

  • go test ./arrow/util -run "TestUnionReflectionHandlesUnsetAndNilOneofValues|TestIsNullDoesNotMutateReflectionState|TestGetMapKeyRejectsUnsupportedType|TestMapAppendReturnsContextualErrorForUnsupportedKey|TestAppendValueOrNull"

@fallintoplace fallintoplace requested a review from zeroshade as a code owner July 5, 2026 18:46
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.

1 participant