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

Type URLs can have any host and even include URI scheme #636

Merged
merged 1 commit into from
Nov 15, 2023

Conversation

jhump
Copy link
Member

@jhump jhump commented Nov 15, 2023

The previous implementation assumed that the type_url field in an Any would always have a type.googleapis.com/ prefix. Though that is typical in practice, it is not actually required per the spec for that field. In fact, protoc allows the use of Any messages (inside message literals for complex option values) that contain a prefix of type.googleprod.com/ (therefore, so does the buf CLI).

The way all protobuf runtimes handle Any is to instead look at the last path element and ignore the prefix (which is also mentioned in the spec for the type_url field). So this makes the code more resilient to unexpected values for type URLs. Previously, the ErrorDetail.Type() method would return the full URL, instead of the type name, in the event that the URL had an unexpected prefix.

Copy link
Member

@akshayjshah akshayjshah left a comment

Choose a reason for hiding this comment

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

Good catch!

@jhump jhump merged commit 2542e8a into main Nov 15, 2023
10 checks passed
@jhump jhump deleted the jh/type-url-prefix-not-constant branch November 15, 2023 16:06
@jhump jhump added the bug Something isn't working label Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants