Skip to content

x/oauth2: ExampleJWTConfig refers to unknown identifier: JWTConfig #68839

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

Closed
mengzhuo opened this issue Aug 12, 2024 · 4 comments
Closed

x/oauth2: ExampleJWTConfig refers to unknown identifier: JWTConfig #68839

mengzhuo opened this issue Aug 12, 2024 · 4 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@mengzhuo
Copy link
Contributor

Go version

83d9afe

Output of go env in your module/workspace:

"sources": [
    {
      "gitilesCommit": {
        "host": "go.googlesource.com",
        "id": "83d9afefead685d9da8e993e064cbe695111110c",
        "project": "go",
        "ref": "refs/heads/master"
      }
    },
    {
      "gitilesCommit": {
        "host": "go.googlesource.com",
        "id": "b52af7d5b4e39d5bb1ee067d8aa110fcce9e4cc7",
        "project": "oauth2",
        "ref": "refs/heads/master"
      }
    }

What did you do?

I found this error during inspection on riscv64 builder failure.

https://logs.chromium.org/logs/golang/buildbucket/cr-buildbucket/8739983205269594385/+/u/step/17/log/2

What did you see happen?

[I2024-08-10T15:53:48.314465Z 3482694 0 sink.go:276] SinkServer: warm-up started
[I2024-08-10T15:53:48.314693Z 3482694 0 sink.go:346] SinkServer: starting HTTP server...
[I2024-08-10T15:53:48.317957Z 3482694 0 sink.go:281] SinkServer: warm-up ended
[I2024-08-10T15:53:48.318864Z 3482694 0 cmd_stream.go:492] rdb-stream: starting the test command - ["/home/swarming/.swarming/w/ir/cache/tools/bin/result_adapter" "go" "-v=false" "-dump-json" "/home/swarming/.swarming/w/ir/x/w/go.testjson" "--" "/home/swarming/.swarming/w/ir/x/w/goroot/bin/go" "test" "-json" "-short" "-timeout=20m0s" "./..."]
# golang.org/x/oauth2/jwt_test
# [golang.org/x/oauth2/jwt_test]
jwt/example_test.go:13:1: ExampleJWTConfig refers to unknown identifier: JWTConfig
ok  	golang.org/x/oauth2	0.091s
ok  	golang.org/x/oauth2/authhandler	0.029s
ok  	golang.org/x/oauth2/clientcredentials	0.033s
ok  	golang.org/x/oauth2/endpoints	0.015s
ok  	golang.org/x/oauth2/google	3.014s
ok  	golang.org/x/oauth2/google/downscope	0.022s
ok  	golang.org/x/oauth2/google/externalaccount	0.147s
ok  	golang.org/x/oauth2/google/internal/externalaccountauthorizeduser	0.026s
ok  	golang.org/x/oauth2/google/internal/stsexchange	0.038s
ok  	golang.org/x/oauth2/internal	0.053s
ok  	golang.org/x/oauth2/jira	0.043s
ok  	golang.org/x/oauth2/jws	4.091s
FAIL	golang.org/x/oauth2/jwt [build failed]
Warning: no '=' in invocation-link-artifacts pair: "", ignoring
[I2024-08-10T15:55:34.623922Z 3482694 0 cmd_stream.go:488] rdb-stream: the test process terminated
[I2024-08-10T15:55:34.624356Z 3482694 0 sink.go:371] SinkServer: shutdown started
[I2024-08-10T15:55:34.624546Z 3482694 0 sink.go:349] SinkServer: HTTP server stopped with "http: Server closed"
[I2024-08-10T15:55:34.624652Z 3482694 0 sink_server.go:96] SinkServer: draining TestResult channel started
[I2024-08-10T15:55:36.200549Z 3482694 0 sink_server.go:98] SinkServer: draining TestResult channel ended
[I2024-08-10T15:55:36.200729Z 3482694 0 sink_server.go:100] SinkServer: draining Artifact channel started
[I2024-08-10T15:55:36.629527Z 3482694 0 sink_server.go:102] SinkServer: draining Artifact channel ended
[I2024-08-10T15:55:36.629702Z 3482694 0 sink.go:374] SinkServer: shutdown completed successfully
[I2024-08-10T15:55:36.629800Z 3482694 0 cmd_stream.go:420] rdb-stream: exiting with 1

What did you expect to see?

Test pass

@gopherbot gopherbot added this to the Unreleased milestone Aug 12, 2024
@cagedmantis cagedmantis added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Aug 13, 2024
@millerresearch
Copy link
Contributor

This is a vet error, triggered by the declaration of function ExampleJWTConfig which is contrary to the convention (documented in go help testfunc) that

Godoc displays the body of ExampleXxx to demonstrate the use of the function, constant, or variable Xxx.

So when vet sees a function named ExampleJWTConfig, it expects to see a symbol JWTConfig declared by the package x/oauth2/jwt, which is not the case. The error message is a bit of misdirection because ExampleJWTConfig does not actually "refer to" the undefined symbol, it's just an inference being made by vet.

A simple fix would be to rename ExampleJWTConfig to ExampleConfig, which may have been the original intention: the example function does show the use of the Config type declared in the package.

@gopherbot
Copy link
Contributor

Change https://go.dev/cl/607015 mentions this issue: oauth2/jwt: rename ExampleJWTConfig to ExampleConfig to avoid vet error

@ianlancetaylor
Copy link
Member

Fixed by https://go.dev/cl/606878. Apologies: I forgot about this issue when I sent that CL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

6 participants