fix: clarify missing repository errors#166
Conversation
|
@charles-openclaw is attempting to deploy a commit to the naheel0's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughSummary by CodeRabbit
Walkthrough
ChangesAPI Error Handling & Branch Resolution
Sequence DiagramsequenceDiagram
participant Client
participant GitHubAPI
participant toRepoAccessError
Client->>GitHubAPI: request (repos/git)
GitHubAPI-->>Client: error response (status, headers, data.message)
Client->>toRepoAccessError: pass error response
toRepoAccessError-->>Client: RepoAccessError(status=429, code=RATE_LIMITED) when headers/message indicate rate limiting
🎯 4 (Complex) | ⏱️ ~45 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/lib/octokit.ts (1)
85-91: 💤 Low valueConsider adding a brief inline comment explaining the status code transformation.
The code intentionally returns HTTP 401 for a 403 response (when no user token is present) to trigger the
authRequiredUX path in the downstream route handler. This is a valid design choice, but the status code remapping could confuse future maintainers.📝 Suggested comment
if (status === 403 && !hasUserAccessToken) { + // Return 401 to trigger authRequired UX (login button) since the user may + // need to authenticate to access a private repository. return new RepoAccessError( "Repository not accessible. It may be private or unavailable. Log in with GitHub if you need access to a private repository.", 401, "AUTH_REQUIRED", ); }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/lib/octokit.ts` around lines 85 - 91, Add a brief inline comment above the RepoAccessError return in the code path that checks "if (status === 403 && !hasUserAccessToken)" explaining that a 403 from GitHub is intentionally remapped to a 401 to trigger the downstream "authRequired" UX flow; reference the RepoAccessError construction and the condition (status === 403 && !hasUserAccessToken) so future maintainers understand this status-code transformation is deliberate and tied to the auth UX.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/lib/octokit.ts`:
- Around line 85-91: Add a brief inline comment above the RepoAccessError return
in the code path that checks "if (status === 403 && !hasUserAccessToken)"
explaining that a 403 from GitHub is intentionally remapped to a 401 to trigger
the downstream "authRequired" UX flow; reference the RepoAccessError
construction and the condition (status === 403 && !hasUserAccessToken) so future
maintainers understand this status-code transformation is deliberate and tied to
the auth UX.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: d995afc7-d38e-4351-96d2-b1938a708537
📒 Files selected for processing (1)
src/lib/octokit.ts
aedc701 to
56c5b8d
Compare
|
Summary of fix:\n- Resolve default_branch name to a tree SHA via |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/lib/octokit.ts`:
- Around line 168-170: The current fallback uses getNestedString(branch,
["commit","sha"]) which returns a commit SHA and can error when later passed to
git.getTree; update the logic that sets treeSha so that after attempting
getNestedString(branch, ["commit","commit","tree","sha"]) you do not fallback to
["commit","sha"] directly but instead, if missing, fetch the commit object and
extract its tree SHA (e.g. call octokit.git.getCommit or octokit.repos.getCommit
with the commit SHA from getNestedString(branch, ["commit","sha"]) and set
treeSha = response.data.tree.sha); keep references to treeSha, getNestedString,
branch and the octokit commit-get method to locate and implement this change.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 34c090d6-37a0-4d96-9241-417dea9d6e47
📒 Files selected for processing (1)
src/lib/octokit.ts
| const { data: branch } = await client.rest.repos.getBranch({ | ||
| owner, | ||
| repo, | ||
| branch: repoInfo.default_branch, | ||
| }); |
|
Follow-up pushed in Summary:
Verification:
|
Summary
Repository not found. Please check the URL and try again.fallback when GitHub returns 404 for a repository lookup.Fixes #37
Verification
npm run lintnpx tsc --noEmitgit diff --checkI did not run
npm run build; this change is limited to the Octokit error normalization path.