Skip to content

fix(oauth2lib): stop calling the deprecated net.Error.Temporary in tests - #219

Merged
agrawalradhika-cell merged 1 commit into
google:masterfrom
agrawalradhika-cell:fix/oauth2lib-url-validation
Dec 2, 2026
Merged

agrawalradhika-cell merged 1 commit into
google:masterfrom
agrawalradhika-cell:fix/oauth2lib-url-validation

Conversation

@agrawalradhika-cell

@agrawalradhika-cell agrawalradhika-cell commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes a finding from the google3 import review of oauth2lib/v0.1.0-rc.1 (cl/1033099457): net.Error.Temporary has been deprecated since Go 1.18.

  • TestClassifyTransportErrorForeignContextErrors called netErr.Temporary(). It now checks only Timeout().
  • timeoutError keeps its Temporary method, with a comment saying why: net.Error still requires it, so removing it would make errors.As(err, &netErr) stop matching client timeouts.

There's no behavior change.

The same review also asked to restrict plain http to loopback hosts and to make validateTokenURL as strict as validateEndpoint. Those changes are not in this PR. They would make oauth2lib stricter than Python gcloud and google-auth:

  • google-auth uses token_uri as given.
  • auth/token_host has no validator.
  • gcloud's EndpointOverrideValidator accepts any http:// or https:// host for api_endpoint_overrides/iamcredentials.

Testing

Go 1.27.4: go vet ./... and go test -race -cover ./... (oauth2lib 97.3%, goldenvectors 95.9%).

net.Error.Temporary has been deprecated since Go 1.18. The test now checks
only Timeout(). timeoutError keeps Temporary so that it still implements
net.Error.
@agrawalradhika-cell
agrawalradhika-cell force-pushed the fix/oauth2lib-url-validation branch from 741a953 to e260cc9 Compare December 1, 2026 22:05
@agrawalradhika-cell agrawalradhika-cell changed the title fix(oauth2lib): allow plain http only for loopback hosts and tighten token URL checks fix(oauth2lib): stop calling the deprecated net.Error.Temporary in tests Dec 1, 2026
@agrawalradhika-cell
agrawalradhika-cell merged commit 599c02b into google:master Dec 2, 2026
10 checks passed
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.

3 participants