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

fix: message parameters in querystring #430

Merged
merged 7 commits into from
Dec 6, 2022
Merged

Conversation

bshaffer
Copy link
Contributor

@bshaffer bshaffer commented Nov 30, 2022

This PR addresses two issues happening in our REST query string serialization

  1. Ensures when additionalBindings contains a message with nested fields, the fields are added to the querystring using dot syntax (e.g. interval.startTime)

    Example: in Monitoring V3, we require the interval query string parameter, but this is of type TimeInterval, and should actually end up being interval.startTime and interval.endTime (see the API documentation)

  2. Ensures certain protobuf types are serialized to JSON correctly according to https://developers.google.com/protocol-buffers/docs/proto3#json

    Example: the values for startTime and endTime in the example above should be a formatted date string derived from the Google\Protobuf\Timestamp message.

Other things worth mentioning

  • This will fix an error happening in the Monitoring library when a REST call is made to any RPC with a message object in the additionalBindings descriptors (e.g. listTimeSeries). The error being thrown is Object of class Google\Cloud\Monitoring\V3\TimeInterval could not be converted to string
  • The nested bindings are calculated only one level deep. This means if a nested message has a message as a property, it will be a JSON-encoded string, and will probably not work as expected. This could be fixed with recursion, but I am being conservative on what we need to support here. Also, this new behavior is better than a PHP fatal error.

@bshaffer bshaffer requested review from a team as code owners November 30, 2022 22:35
@bshaffer bshaffer enabled auto-merge (squash) December 6, 2022 20:58
@bshaffer bshaffer merged commit 77bc5e1 into main Dec 6, 2022
@bshaffer bshaffer deleted the fix-queryparam-serialization branch December 6, 2022 20:59
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