Skip to content
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

WIP: Recognize the AllowPartial flag when parsing Any #49

Closed

Conversation

justinsb
Copy link
Contributor

@justinsb justinsb commented Oct 1, 2024

We were not passing down and honoring the AllowPartial flag when parsing anypb.Any.

We were not passing down and honoring the AllowPartial flag when parsing anypb.Any.
@@ -176,7 +176,7 @@ func (d decoder) unmarshalAny(m protoreflect.Message) error {
// Use another decoder to parse the unread bytes for @type field. This
// avoids advancing a read from current decoder because the current JSON
// object may contain the fields of the embedded type.
dec := decoder{d.Clone(), UnmarshalOptions{RecursionLimit: d.opts.RecursionLimit}}
dec := decoder{d.Clone(), UnmarshalOptions{RecursionLimit: d.opts.RecursionLimit, AllowPartial: d.opts.AllowPartial}}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if I should also plumb through DiscardUnknown (or maybe all the options?). Those are the two options that cloud.google.com/go passes today: e.g. https://github.com/googleapis/google-cloud-go/blob/b23a08492a7724ce6f1f95395b7f71feb9b3de66/ai/generativelanguage/apiv1beta/generative_client.go#L600

@justinsb
Copy link
Contributor Author

justinsb commented Oct 1, 2024

Related issue in older proto lib is golang/protobuf#1620

Copy link

@puellanivis puellanivis left a comment

Choose a reason for hiding this comment

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

Thank you for your interest into contributing to this project.

Unfortunately this project does not accept GitHub pull requests as the source-of-truth for this project is hosted at https://go.googlesource.com/protobuf. This project page on GitHub is a mirror of that other repository.

If you would like to contribute to this project, please follow the contribution guidelines for instructions on how to send a change. If the change you'd like to make is more substantial or introduces any new features, then it should first be discussed on the issue tracker.

Comment on lines +2207 to +2211
wantMessage: func() proto.Message {
return &anypb.Any{
TypeUrl: "type.googleapis.com/google.protobuf.Empty",
}
}(),

Choose a reason for hiding this comment

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

This function wrapping is unnecessary. Since the function doesn’t do anything other than return an anypb.Any composite literal.

@justinsb
Copy link
Contributor Author

justinsb commented Oct 2, 2024

Thank you @puellanivis - I commented on the related issue golang/protobuf#1620 (comment) and opened a CL in https://go-review.git.corp.google.com/c/protobuf/+/617516

Thank you also to @chressie for the pointers this morning!

I'm going to close this PR.

@justinsb justinsb closed this Oct 2, 2024
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