Skip to content

Add detail for gRPC/HTTP transcoding#922

Open
jskeet wants to merge 3 commits intoaip-dev:masterfrom
jskeet:transcoding
Open

Add detail for gRPC/HTTP transcoding#922
jskeet wants to merge 3 commits intoaip-dev:masterfrom
jskeet:transcoding

Conversation

@jskeet
Copy link
Copy Markdown
Contributor

@jskeet jskeet commented Jul 21, 2022

  • Define which fields are mapped to query parameters (and how)
  • Specify behavior (and limitations) for fields represented in
    both the body and the URI

Comment thread aip/general/0127.md Outdated
- Define which fields are mapped to query parameters (and how)
- Specify behavior (and limitations) for fields represented in
  both the body and the URI
Copy link
Copy Markdown
Contributor

@vchudnov-g vchudnov-g left a comment

Choose a reason for hiding this comment

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

LGTM, just some suggestions for links to additional info.

Comment thread aip/general/0127.md
discussed in [AIP-136][].
- RPCs **should not** use `put` or `custom`.
- The corresponding value represents the URI.
- The corresponding value represents the path in the URI.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

(URN, in the nomenclature of https://en.wikipedia.org/wiki/Uniform_Resource_Identifier, though it seems this term is not commonly used)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I suspect that far more readers will understand "path in the URI" than "URN".

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Agreed. (Hence the parentheses)

Comment thread aip/general/0127.md
and the URI, the values **must** be identical. The server behavior when
this constraint is violated is unspecified.
- Eligible fields which are not represented in the URI path or the body are mapped
to URI query parameters.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It might be useful to include a reference to https://developers.google.com/protocol-buffers/docs/proto3#json, which has more details (and may get updated based on our parallel work)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's already referenced earlier in the body part: "The request body is encoded as JSON
as defined by protocol buffers' canonical JSON encoding" where "JSON encoding" is a link.

Comment thread aip/general/0127.md
this constraint is violated is unspecified.
- Eligible fields which are not represented in the URI path or the body are mapped
to URI query parameters.
- Only singular primitive, repeated primitive, and singular message type fields
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It would be good to link to the source of truth https://github.com/googleapis/googleapis/blob/dbfbfdb38a2f891384779a7ee31deb15adba6659/google/api/http.proto#L61 .... but is there a web-friendly, auto-up-to-date view of this somewhere we can use?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've added a link to the proto (in the master branch, which will be redirected accordingly if we rename it to main) earlier - I think that's probably clearer than trying to link to individual bits of documentation for each section.

Comment thread aip/general/0127.md
- Eligible fields which are not represented in the URI path or the body are mapped
to URI query parameters.
- Only singular primitive, repeated primitive, and singular message type fields
are eligible to be represented as query parameters.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: Consider simpler wording: s/are eligible to be/may be/

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'd prefer to keep it as "eligible" as "may" suggests something that's optional - a client might or might not decide to encode some fields as URI query parameters. In reality, a client must do that, because the fields are eligible to be encoded. Happy to noodle on alternatives to "eligible" - I'd just prefer to avoid "may".

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh, I see what you mean. On a naive read, "eligible" registered to me as something you can choose to do, i.e. "may". But you are using it in an algorithmic sense, tying back to your previous line.

Could we say instead:

Fields which are not represented in the URI path or the body are mapped to URI query parameters if and only if they 
are singular primitive, repeated primitive, or singular message type fields.
- Repeated primitive...
- For message-type fields....

And that also brings up a question to clarify: what about repeated message fields? Should it be an error for there to be an http binding that does not map them to the body, since they can't be represented in the path or query params and so would incur data loss if non-empty?

Copy link
Copy Markdown
Contributor Author

@jskeet jskeet left a comment

Choose a reason for hiding this comment

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

I've added a new commit with a link to http.proto.

Comment thread aip/general/0127.md
discussed in [AIP-136][].
- RPCs **should not** use `put` or `custom`.
- The corresponding value represents the URI.
- The corresponding value represents the path in the URI.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I suspect that far more readers will understand "path in the URI" than "URN".

Comment thread aip/general/0127.md
and the URI, the values **must** be identical. The server behavior when
this constraint is violated is unspecified.
- Eligible fields which are not represented in the URI path or the body are mapped
to URI query parameters.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's already referenced earlier in the body part: "The request body is encoded as JSON
as defined by protocol buffers' canonical JSON encoding" where "JSON encoding" is a link.

Comment thread aip/general/0127.md
- Eligible fields which are not represented in the URI path or the body are mapped
to URI query parameters.
- Only singular primitive, repeated primitive, and singular message type fields
are eligible to be represented as query parameters.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'd prefer to keep it as "eligible" as "may" suggests something that's optional - a client might or might not decide to encode some fields as URI query parameters. In reality, a client must do that, because the fields are eligible to be encoded. Happy to noodle on alternatives to "eligible" - I'd just prefer to avoid "may".

Comment thread aip/general/0127.md
this constraint is violated is unspecified.
- Eligible fields which are not represented in the URI path or the body are mapped
to URI query parameters.
- Only singular primitive, repeated primitive, and singular message type fields
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I've added a link to the proto (in the master branch, which will be redirected accordingly if we rename it to main) earlier - I think that's probably clearer than trying to link to individual bits of documentation for each section.

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.

4 participants