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

AIP-4236 - API Versioning for Version-aware clients #1331

Merged
merged 16 commits into from
May 22, 2024

Conversation

parthea
Copy link
Contributor

@parthea parthea commented Mar 23, 2024

The following is an AIP for the API Versioning feature in client library generators.

Googlers see b/330951736


Requests which contain the API version, must include either an HTTP query
parameter `$apiVersion` or HTTP header `X-Goog-Api-Version`, but not both.

Copy link

@zhumin8 zhumin8 May 7, 2024

Choose a reason for hiding this comment

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

To guide consistent behavior across languages when user attempts to set a user header of the same key, this could be to override an existing version that ships with client library, or attempting to add this header when server does not opt in for this feature.
Let's state something along the lines of:

Suggested change
Generated client library should not let users override the `X-Goog-Api-Version` HTTP header. This should be regardless if the service is annotated with [google.api.api_version].

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer not to add that, personally. There's only so much you can do to protect users who are determined to do weird things. The chances of someone accidentally setting that header are very slim - and if someone really wants to do so, they can always send a request directly from an HTTP client. We definitely shouldn't provide any way of specifically overriding the header - but I don't think "code that allows headers to be specified" should be modified to try to prevent this.

Copy link

Choose a reason for hiding this comment

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

There's only so much you can do to protect users who are determined to do weird things.

I agree on this. On the other hand, it also seems valuable to give user usable feedback if we don't intend have this overriden.

To add a bit context in Java, we already have some logic trying to resolve conflict between internal header set by defaults and user headers. I am inclined to add logic to throw exception when user attempt to add a header with key "x-goog-api-version" (draft pr). Alternative to this is no change to this existing logic, which will throw exception only when internal header has this key (that's when service has a api version). I don't feel too strongly, but the first one gives a bit more consistent feedback.

I realize this is only dealing with an edge case, but also feel that this case is language agnostic, so wanted to check if we want to deal with it consistently across languages.

WDTY?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think if Java wants to attempt to stop the user from doing it, that's fine - I don't think it should be in the AIP.

Copy link
Contributor

@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'm generally happy with this as a first pass. I suspect I may have some suggested changes over time, but that's a different matter :)


Requests which contain the API version, must include either an HTTP query
parameter `$apiVersion` or HTTP header `X-Goog-Api-Version`, but not both.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer not to add that, personally. There's only so much you can do to protect users who are determined to do weird things. The chances of someone accidentally setting that header are very slim - and if someone really wants to do so, they can always send a request directly from an HTTP client. We definitely shouldn't provide any way of specifically overriding the header - but I don't think "code that allows headers to be specified" should be modified to try to prevent this.

@parthea parthea requested review from zhumin8 and noahdietz and removed request for zhumin8 May 7, 2024 14:22
@parthea parthea assigned noahdietz and unassigned jskeet May 7, 2024
@parthea parthea changed the title draft: AIP-4236 - API Versioning for Version-aware clients AIP-4236 - API Versioning for Version-aware clients May 16, 2024
@parthea
Copy link
Contributor Author

parthea commented May 16, 2024

@noahdietz PTAL

Copy link
Collaborator

@noahdietz noahdietz left a comment

Choose a reason for hiding this comment

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

Please review all comments before responding to an individual one. Some are on the same line and impact each other.


# Version-aware clients

APIs may choose to annotate services with [google.api.api_version]. If
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
APIs may choose to annotate services with [google.api.api_version]. If
APIs may choose to annotate services with [`google.api.api_version`][]. If

I think we still need the empty [] for an implicit link.

Also let's format the annotation name as code, might require updating the definition text as well.

Applies here and throughout.


# Version-aware clients

APIs may choose to annotate services with [google.api.api_version]. If
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
APIs may choose to annotate services with [google.api.api_version]. If
APIs can annotate services with [google.api.api_version]. If

Don't use requirement words in non-requirement contexts

# Version-aware clients

APIs may choose to annotate services with [google.api.api_version]. If
[google.api.api_version] is specified, version-aware clients **must** include
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need to hyperlink every use of google.api.api_version?

[google.api.api_version] is specified, version-aware clients **must** include
the value of [google.api.api_version] in the request to the API. This allows
services to abide by the schema and behavior of the service at the time that
this API version was deployed. The format of the API version must be treated
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
this API version was deployed. The format of the API version must be treated
this API version was deployed. The format of the API version **must** be treated

I'm guessing this is a requirement?

aip/client-libraries/4236.md Outdated Show resolved Hide resolved
aip/client-libraries/4236.md Outdated Show resolved Hide resolved
aip/client-libraries/4236.md Outdated Show resolved Hide resolved
aip/client-libraries/4236.md Outdated Show resolved Hide resolved
aip/client-libraries/4236.md Outdated Show resolved Hide resolved
aip/client-libraries/4236.md Outdated Show resolved Hide resolved
@parthea parthea requested a review from noahdietz May 21, 2024 13:59
aip/client-libraries/4236.md Outdated Show resolved Hide resolved
aip/client-libraries/4236.md Outdated Show resolved Hide resolved
created: 2024-05-16
---

# Version-aware clients
Copy link
Collaborator

Choose a reason for hiding this comment

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

I does! A few more tweaks thanks Tony :)

@parthea parthea requested a review from noahdietz May 21, 2024 16:07
Copy link
Collaborator

@noahdietz noahdietz left a comment

Choose a reason for hiding this comment

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

Just one more comment - I liked that opaque value requirement in the guidance, it is important stuff

Comment on lines 35 to 38
Clients must treat the value of `google.api.api_version` as opaque to ensure robust
compatibility. This means that the specific format or structure of the version string
should not be parsed or interpreted for any purpose beyond identifying the intended API
version. By relying on this opaque identifier, clients avoid making assumptions about the
Copy link
Collaborator

Choose a reason for hiding this comment

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

So these first two sentences would be really good in the guidance section e.g.

Clients **must** treat the value of `gogle.api.api_version as opaque. Specifically, the value **must not**
be interpreted or parsed in any way.

Then this subsection could start:

Treating the `google.api.api_version` value as opaque is important to ensuring robust
compatibility guarantees. By relying on....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in a228cba

aip/client-libraries/4236.md Outdated Show resolved Hide resolved
aip/client-libraries/4236.md Outdated Show resolved Hide resolved
parthea and others added 2 commits May 22, 2024 12:25
Co-authored-by: Noah Dietz <noahdietz@users.noreply.github.com>
Co-authored-by: Noah Dietz <noahdietz@users.noreply.github.com>
@parthea parthea enabled auto-merge (squash) May 22, 2024 16:25
@parthea parthea merged commit 50046a5 into master May 22, 2024
2 checks passed
@parthea parthea deleted the api-versioning-draft branch May 22, 2024 16:25
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.

None yet

4 participants