Repository navigation
fix: Improve gitlab permissions logging - #659
Merged
Merged
Conversation
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge The restructuring of error handling in
Files Reviewed (2 files)
|
jeanduplessis
approved these changes
Mar 1, 2026
jeanduplessis
left a comment
Contributor
There was a problem hiding this comment.
Nit: there's a lot of "magic string" values being used and inconsistent use of variables vs strings. Some areas use PLATFORM.GITLAB, others just "gitlab" or "github".
It would be good to make this code consistent.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Diagnosis
We’re seeing a consistent failure when users launch code reviews on their GitLab instance.
Root Cause: Error swallowing in
prepareReviewPayloadcauses GitLab code reviews to clone without authentication.The flow works like this:
prepareReviewPayload()attempts to create a Project Access Token (PrAT) for cloningtry/catch(line 305, originally designed for GitHub token failures) catches this re-thrown error and swallows it, logging to Sentry but continuing without a tokengitToken: undefined"Failed to clone repository"failureThis explains why:
flytogether-mpreviews fail — PrAT creation consistently fails for this user, and the error is swalloweddevproductsreviews succeed — PrAT creation sometimes works (the 3 successes on Feb 25-26), but when it fails, same swallowing happensSecondary issue: The
platformfield was never passed through the code review orchestrator to cloud-agent, forcing it to rely on a heuristic (gitUrl?.includes('gitlab')) that would fail for self-hosted instances with non-"gitlab" domain names.Changes Made
1.
src/lib/code-reviews/triggers/prepare-review-payload.tsplatformfield toSessionInputtype and to both GitHub/GitLab session input construction, so cloud-agent receives explicit platform info instead of relying on URL heuristics.2.
cloudflare-code-review-infra/src/types.tsplatformfield to theSessionInputinterface so it flows through the orchestrator to cloud-agent.Next Steps
After deploying, the failing reviews will now surface clear error messages like
"Failed to create Project Access Token for GitLab code review on flytogether-mp/static-site. Error: ..."instead of the misleading"Failed to clone repository". This will reveal the underlying PrAT failure reason — likely a permissions issue (user needs Maintainer role) or PrAT feature disabled at the project/group level. Check Sentry for the capturedauthErrorexceptions from these users to confirm.