Skip to content

Conversation

@dandavison
Copy link
Contributor

@dandavison dandavison commented Nov 26, 2025

Currently, DeserializeComponentRef given empty input yields a zero-value ComponentRef. Although this matches the behavior of proto Unmarshal, we don't want to support empty serialized refs. A zero-value ComponentRef compares less than other values, but it's otherwise mostly invalid (and can't be serialized).


Note

Make DeserializeComponentRef error on empty input and add tests for nil/empty cases.

  • chasm:
    • DeserializeComponentRef: Return error on empty input (len(data) == 0); add errors import.
    • Tests: Update TestSerializeDeserialize to assert errors for nil and empty byte slices; retain serialization roundtrip checks.

Written by Cursor Bugbot for commit f968d82. This will update automatically on new commits. Configure here.

@dandavison dandavison requested review from a team as code owners November 26, 2025 03:09
@dandavison dandavison requested a review from yycptt November 26, 2025 03:15
chasm/ref.go Outdated
// Provides caller the access to information including ExecutionKey, Archetype, and ShardingKey.
func DeserializeComponentRef(data []byte) (ComponentRef, error) {
if len(data) == 0 {
return ComponentRef{}, serviceerror.NewInternal("empty chasm component ref")
Copy link
Member

Choose a reason for hiding this comment

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

if we are using service error, let's switch to InvalidArgument.

// Provides caller the access to information including ExecutionKey, Archetype, and ShardingKey.
func DeserializeComponentRef(data []byte) (ComponentRef, error) {
if len(data) == 0 {
return ComponentRef{}, errors.New("empty chasm component ref")
Copy link

Choose a reason for hiding this comment

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

Bug: Should use InvalidArgument instead of errors.New (Bugbot Rules)

The error returned for empty input uses errors.New instead of serviceerror.NewInvalidArgument. The PR discussion explicitly requested switching to InvalidArgument, and this matches the codebase pattern for invalid input validation as seen in path_encoder.go and visibility.go.

Fix in Cursor Fix in Web

// Provides caller the access to information including ExecutionKey, Archetype, and ShardingKey.
func DeserializeComponentRef(data []byte) (ComponentRef, error) {
if len(data) == 0 {
return ComponentRef{}, errors.New("empty chasm component ref")
Copy link
Member

Choose a reason for hiding this comment

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

This will cause unnecessary retries so I can't approve it.

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