-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Path replacement of endpoint in Drive /upload operation #2623
Comments
Interesting, thanks for the detailed report. I kind of think you've been depending on some emergent behavior. ResolveRelative is documented saying it strips path segments trailing the host: I reproduced the behavior you've observed here: https://go.dev/play/p/CQFiZZgSsy8 func main() {
e := "https://foo.googleapis.com/bar/baz/"
p1 := "v1/fooer"
p2 := "/v1/fooer"
p3 := "fooer"
fmt.Println("resolved endpoint:", googleapi.ResolveRelative(e, ""))
fmt.Println("resolved p1:", googleapi.ResolveRelative(e, p1))
fmt.Println("resolved p2:", googleapi.ResolveRelative(e, p2))
fmt.Println("resolved p3:", googleapi.ResolveRelative(e, p3))
}
You are right that it seems that when the When I take the trailing slash off of the endpoint it starts trimming differently:
This will take a bit of investigating - I am worried about changing Edit: fix formatting |
Thanks for your attention on this @noahdietz About things getting weirder, check this out: grep --include=\*.go -rn -e 'ResolveRelative(.*, "' It returns 20k+ occurrences, yes, a lot of them. But when you run: grep --include=\*.go -rn -e 'ResolveRelative(.*, "/' Only 74 starts with a This commit replaced the old code for the Edit: |
When we create a service with endpoint (option#WithEndpoint) using host and path, ie:
https://myhost.com/connections/google/
it works well for operations like folder creation, as the URL will replaced by:
https://myhost.com/connections/google/files
Replaced by:
google-api-go-client/drive/v3/drive-gen.go
Line 5520 in 0077748
But for media upload operations, like file creation, it is removing our endpoint path here:
google-api-go-client/drive/v3/drive-gen.go
Line 5522 in 0077748
Instead of calling this:
https://myhost.com/connections/google/upload/drive/v3/files
it's calling:
https://myhost.com/upload/drive/v3/files
The reason is the slash
/
at the beggining of therelstr
during thegoogleapi.ResolveRelative
func call.This is the only operation that starts with slash, all others (like files, comments, etc) are appended to our custom endpoint.
Is it an issue or intentional?
The text was updated successfully, but these errors were encountered: