8000 chore: improve error handling for device code exchange failure by Emyrk · Pull Request #11708 · coder/coder · GitHub
[go: up one dir, main page]

Skip to content

chore: improve error handling for device code exchange failure #11708

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

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
linting
  • Loading branch information
Emyrk committed Jan 19, 2024
commit 2cd35843fd8ffce9375dea7874bfab4e0442be55
3 changes: 2 additions & 1 deletion coderd/coderdtest/oidctest/idp.go
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,9 @@ func (f *FakeIDP) DeviceLogin(t testing.TB, client *codersdk.Client, externalAut
// the verification url. No additional user input is needed.
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
defer cancel()
_, err = client.Request(ctx, http.MethodPost, device.VerificationURI, nil)
resp, err := client.Request(ctx, http.MethodPost, device.VerificationURI, nil)
require.NoError(t, err)
defer resp.Body.Close()

// Now we need to exchange the device code for an access token. We do this
// in this method because it is the user that does the polling for the device
Expand Down
2 changes: 1 addition & 1 deletion coderd/externalauth/externalauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ func (c *DeviceAuth) AuthorizeDevice(ctx context.Context) (*codersdk.ExternalAut
// 429 returns a plaintext payload with a message.
return nil, xerrors.New(fmt.Sprintf("rate limit hit, unable to authorize device. %s", retryIn))
case mediaType == "application/x-www-form-urlencoded":
return nil, xerrors.Errorf("%s payload response is form-url encoded, expected a json payload", resp.StatusCode)
return nil, xerrors.Errorf("status_code=%d, payload response is form-url encoded, expected a json payload", resp.StatusCode)
default:
return nil, fmt.Errorf("status_code=%d, mediaType=%s: %w", resp.StatusCode, mediaType, err)
}
Expand Down
0