googleapis / googleapis/gapic-showcase
REST-encoding of `Any` fields omits `@type`
- Dominant language
- Go
- Stars
- 183
- Forks
- 55
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 8
Description
In the branch `gce_error_details`, Showcase populates an array of error details, These details are declared as `repeated google.protobuf.Any details` [here](https://github.com/googleapis/googleapis/blob/7466a5b356efdc34beb322a91f341f9e9463e802/google/rpc/status.proto#L48C3-L48C39), but the JSON-encoded error response does not populate the `@type` field of each `Any`-type element of `details`. The JSON encoding of `google.protobuf.Any` should include such a field ([ref](https://github.com/protocolbuffers/protobuf/blob/7e9e8db4f6851b30494bafa16717acf833980546/src/google/protobuf/any.proto#L104)).
If I start the Showcase server from that branch and then I run `curl`, this is what I get (notice the lack of `@type` fields):
```
> curl -i -X POST -H "X-Goog-Api-Client: rest/0.0.0 gapic/0.0.0" -H 'Content-Type: application/json' http://localhost:7469/v1beta1/echo:echo -d'{"error": {"code": 8,"message":"Main error message"}, "generateErrorDetails": true} '
HTTP/1.1 429 Too Many Requests
Date: Thu, 25 Apr 2024 23:07:46 GMT
Content-Length: 1292
Content-Type: text/plain; charset=utf-8
{"error":{"code":429,"message":"Main error message","details":[{"reason":"(showcase:ErrorInfo) RPC requested we populate all error details","domain":"googleapis.com"},{"retry_delay":{"seconds":3,"nanos":14159265}},{"stack_entries":["frame 1","frame 2","frame3"],"detail":"(showcase:DebugInfo) sample stack frames"},{"violations":[{"subject":"(showcase:QuotaFailure) showcase-testing:fake errors","description":"This is fake quota error 0"},{"subject":"(showcase:QuotaFailure) showcase-testing:more fake errors","description":"This is fake quota error 1"}]},{"violations":[{"type":"Fake Type 0","subject":"(showcase:PreconditionFailure) showcase-testing:fake errors","description":"This is fake precondition error 0"},{"type":"Fake Type 1","subject":"(showcase:PreconditionFailure) showcase-testing:fake errors","description":"This is fake precondition error 1"}]},{"field_violations":[{"field":"field 0","description":"(showcase:BadRequest) description 0"},{"field":"field 1","description":"(showcase:BadRequest) description 1"}]},{"links":[{"description":"(showcase:Help) Description 0","url":"URL 0"},{"description":"(showcase:Help) Description 1","url":"URL 1"}]},{"locale":"en-US","message":"(showcase:LocalizedMessage) Some message for the user"}],"Body":"","Header":null,"Errors":null}}%
```
Contributor guide
Assessment
This issue has not been assessed yet.