fix(gitlab): refresh expired tokens for GraphQL and REST 401s - #7932
fix(gitlab): refresh expired tokens for GraphQL and REST 401s#7932jackspiece wants to merge 3 commits into
Conversation
GitLab REST APIs return { message: '401 Unauthorized' } for invalid or expired credentials.
Recognize that documented response alongside existing OAuth and GraphQL error shapes.
PKCE authentication can then refresh and retry, including the initial user request.
|
The current e2e run did not report an assertion failure. Cypress stopped emitting output in I tried to rerun the failed job, but fork authors do not have the required repository permission. Could someone with Actions access rerun e2e? |
yanthomasdev
left a comment
There was a problem hiding this comment.
Thanks @jackspiece! The failing test is a flaky test we already had and is unrelated to your PR, I'll rerun checks but the PR looks good to me.
✅ Deploy Preview for decap-cms ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Summary
Fixes #7931.
Related to #7581.
#7854 added refresh and retry behavior for GitLab REST requests, but Apollo HTTP Link still called
fetchdirectly. If the first request after a PKCE access token expired was GraphQL, GitLab returned a 401 and the stored refresh token was never used.This routes Apollo through the existing backend request function and recognizes the documented GraphQL invalid-token response. That keeps refresh coalescing, credential persistence, and the single retry in the same path used by REST.
While checking #7581, I also found that GitLab REST APIs use
{"message":"401 Unauthorized"}for invalid credentials. The existing detector only recognized the OAuthinvalid_tokenshape. This now recognizes both exact REST responses, so an expired token can also be refreshed during the initial/userrequest.Test plan
invalid_tokenbody and GitLab's standard REST 401 body, including refresh during login.Checklist