Byron / google-apis-rs

A binding and CLI generator for all Google APIs
http://byron.github.io/google-apis-rs
Other
1.01k stars 131 forks source link

google_cloudprofiler2: `Profile.profile_bytes` accepts `String` instead of `Vec<u8>` #407

Closed aengelas closed 1 year ago

aengelas commented 1 year ago

I'm attempting to create and upload pprof CPU profiles via the google_cloudprofiler2 crate, but encountering an issue getting the .proto contents into the profile_bytes field of the google_cloudprofiler2::api::Profile struct. As far as I'm aware, a .proto file will not always be valid UTF-8 (maybe never?), and the documentation indicates:

Input only. Profile bytes, as a gzip compressed serialized proto, the format is https://github.com/google/pprof/blob/master/proto/profile.proto.

https://github.com/Byron/google-apis-rs/blob/8e4ec82be7c7425924cb1cf4d3b36070b3424fc8/gen/cloudprofiler2/src/api.rs#L235-L237

It's not clear to me what the expectation is here; I'd assume it would accept something like Vec<u8>, &[u8] or some sort of Byte type. I see in the protobuf definitions that it's a string type, but I assume that protobuf is more lenient with non-utf8 strings?

I'd love a) confirmation that this is an issue; b) guidance on how to fix it. I'm happy to contribute the fix, but there are a lot of moving parts in this repo.

aengelas commented 1 year ago

A coworker correctly pointed out that this works because the bytes are expected to by base64-encoded. I think it'd be worthwhile adding this to the docs, and/or changing the interface to accept Vec<u8> and do the encoding internally. Again, given the auto-generated nature of the interface, I'm not sure if there's a good solution.

Byron commented 1 year ago

It's possible to setup per-API overrides which is currently only done for the YouTube API. However, each kind of override would need to be implemented which can be contributed.

In the hopes that issues serves as documentation, I am closing this issue, but that shouldn't stop anyone to contribute a way to make amendments to the docs on a per-API basis. Thanks for your understanding.