{"record":{"id":"b6e59ee292bb44da","repo":"wtfutil/wtf","slug":"panic-err-b6e59e","errorCode":null,"errorMessage":"panic(err)","messagePattern":"panic\\(err\\)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"modules/spotifyweb/widget.go","lineNumber":100,"sourceCode":"\t\tsettings:    settings,\n\t}\n\n\thttp.HandleFunc(\"/callback\", authHandler)\n\tgo func() {\n\t\terr := http.ListenAndServe(\":\"+callbackPort, nil)\n\t\tif err != nil {\n\t\t\treturn\n\t\t}\n\t}()\n\n\tgo func() {\n\t\t// wait for auth to complete\n\t\tclient = <-tempClientChan\n\n\t\t// use the client to make calls that require authorization\n\t\t_, err := client.CurrentUser()\n\t\tif err != nil {\n\t\t\tpanic(err)\n\t\t}\n\n\t\tplayerState, err = client.PlayerState()\n\t\tif err != nil {\n\t\t\tfmt.Println(err)\n\t\t\tos.Exit(1)\n\t\t}\n\n\t\twidget.client = client\n\t\twidget.playerState = playerState\n\t\twidget.Refresh()\n\t}()\n\n\t// While I wish I could find the reason this doesn't work, I can't.\n\t//\n\t// Normally, this should open the URL to the browser, however it opens the Explorer window in Windows.\n\t// This mostly likely has to do with the fact that the URL includes some very special characters that no terminal likes.\n\t// The only solution would be to include quotes in the command, which is why I do here, but it doesn't work.","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/wtfutil/wtf/blob/bb838c1ccb0f0f3223690df44afdec663d622881/modules/spotifyweb/widget.go#L82-L118","documentation":"The Spotify widget's first-run authorization flow waits on tempClientChan, then calls client.CurrentUser() to verify the token; if that call fails it panics with the raw error. Typical causes are the Spotify auth handshake failing (bad/missing client ID/secret, callback timeout, user denying consent) or the token being invalid/expired at first call. This is module initialization code, so a panic kills the whole app.","triggerScenarios":"Widget starts without a stored valid token: it blocks on tempClientChan for auth, then CurrentUser() returns an error — expired/refresh-failed token, wrong clientID/secret in config, auth server unreachable, or the user never completed the browser auth flow.","commonSituations":"First run without completing the Spotify OAuth login; Spotify app credentials rotated or revoked; system clock skew invalidating tokens; network/proxy blocking accounts.spotify.com; running headless where the callback can't complete.","solutions":["Complete the Spotify authentication flow in the browser when prompted and ensure the callback reaches the app","Verify clientID/clientSecret in the Spotify widget config match your app at developer.spotify.com","Delete cached Spotify tokens/credentials and re-authenticate","Check network access to accounts.spotify.com and api.spotify.com (proxy/firewall); fix clock skew if tokens expire immediately","Wrap or patch the panic path if running unattended so failures degrade gracefully instead of crashing the app"],"exampleFix":"// before\n_, err := client.CurrentUser()\nif err != nil {\n    panic(err)\n}\n// after\n_, err := client.CurrentUser()\nif err != nil {\n    fmt.Printf(\"spotify auth failed: %v\\n\", err)\n    return // skip widget instead of crashing\n}","handlingStrategy":"try-catch","validationCode":"// before starting the widget, check credentials are present\nif cfg.Spotify.ClientID == \"\" || cfg.Spotify.ClientSecret == \"\" {\n    return fmt.Errorf(\"spotify widget requires clientID and clientSecret\")\n}","typeGuard":null,"tryCatchPattern":"// guard module startup against the panic\nfunc startSpotify(wg *sync.WaitGroup) {\n    defer func() {\n        if r := recover(); r != nil {\n            log.Printf(\"spotify widget disabled, auth failed: %v\", r)\n        }\n    }()\n    wg.Add(1)\n    makeModule(wg, makeSpotifyWidget)\n}","preventionTips":["Complete the OAuth browser flow on first run; don't run headless without a cached token","Keep clientID/clientSecret current at developer.spotify.com","Clear stale cached tokens after credential rotation","Ensure outbound access to accounts.spotify.com and api.spotify.com"],"tags":["go","panic","spotify","oauth","auth"],"backgroundTag":"oauth-token-error","analyzedSha":"bb838c1ccb0f0f3223690df44afdec663d622881","analyzedAt":"2026-09-03T17:02:45.030Z","contentChangedAt":"2026-09-03T17:02:45.030Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}