feat: show not-found UI when an Ask GitHub repo doesn't exist#1432
Merged
Conversation
Instead of throwing a ServiceErrorException (error boundary) when a repository doesn't exist on GitHub, the /askgh/[owner]/[repo] page now renders a dedicated "Repository not found" page. To distinguish "repo doesn't exist" from other failures, the signal is plumbed through the stack: - backend: experimental_addGithubRepo catches the Octokit 404 (new isNotFound helper) and returns a 404 instead of a generic 500. - web action: addGithubRepo maps a 404 response to a new repositoryNotFound service error (REPOSITORY_NOT_FOUND). - page: renders <RepoNotFound> for REPOSITORY_NOT_FOUND, and only throws for other errors. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
WalkthroughThe experimental Ask GitHub flow now detects missing GitHub repositories, returns a typed 404 error through the web layer, and renders a dedicated repository-not-found page with a link back home. ChangesAsk GitHub repository-not-found flow
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant AskGitHubPage
participant WorkerAPI
participant BackendAPI
participant GitHub
participant RepoNotFound
AskGitHubPage->>WorkerAPI: Add owner/repo
WorkerAPI->>BackendAPI: Request repository lookup
BackendAPI->>GitHub: Fetch repository
GitHub-->>BackendAPI: 404 not found
BackendAPI-->>WorkerAPI: HTTP 404
WorkerAPI-->>AskGitHubPage: REPOSITORY_NOT_FOUND
AskGitHubPage->>RepoNotFound: Render owner/repo error page
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
Contributor
|
@brendan-kellam your pull request is missing a changelog! |
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.
Summary
When a repository doesn't exist on GitHub, the experimental Ask GitHub repo page (
/askgh/[owner]/[repo]) previously threw aServiceErrorException, surfacing the generic error boundary. It now renders a dedicated "Repository not found" page instead. Other failures (worker down, unexpected errors) still throw as before.The problem
The old code couldn't tell "repo doesn't exist" apart from any other failure. The backend threw the Octokit 404 into Express's default handler (→ HTTP 500), and the
addGithubRepoaction collapsed every non-OK response into a genericunexpectedError. So a dedicated not-found signal is plumbed through the stack.Changes
Backend (
packages/backend/src/)errors.ts— addedisNotFound(err)alongside the existingisUnauthorized/isForbidden/isGone, reusing the samegetStatushelper.api.ts—experimental_addGithubRepowraps theoctokit.rest.repos.get()call in try/catch: a 404 returnsres.status(404), anything else re-throws (unchanged behavior).Web (
packages/web/src/)lib/serviceError.ts— added arepositoryNotFound(repository)helper using the already-definedErrorCode.REPOSITORY_NOT_FOUND(previously an unused enum member).features/workerApi/actions.ts—addGithubRepomaps a 404 response torepositoryNotFound(...); all other failures stayunexpectedError.app/(app)/askgh/[owner]/[repo]/page.tsx— returns theServiceErrorfrom the repo-resolution block instead of throwing inside the IIFE; the page renders<RepoNotFound>whenerrorCode === REPOSITORY_NOT_FOUND, and only throwsServiceErrorExceptionfor everything else.app/(app)/askgh/[owner]/[repo]/components/repoNotFound.tsx— new server component styled to matchrepoIndexedGuard.tsx.Verification
tsc --noEmitclean on both@sourcebot/backendand@sourcebot/web(no new errors in changed files).errors.test.tspasses (32/32).Not driven end-to-end against a live stack (needs Postgres/Redis/worker/web + a real GitHub call).
🤖 Generated with Claude Code
Note
Low Risk
Experimental Ask GitHub UX and error mapping only; no auth, billing, or core indexing behavior changes beyond clearer 404 handling.
Overview
Ask GitHub (
/askgh/[owner]/[repo]) now shows a dedicated Repository not found page when GitHub has no such repo, instead of hitting the generic error boundary.The worker
experimental/add-github-repopath maps Octokit 404 to HTTP 404 via newisNotFound;addGithubRepoturns that intorepositoryNotFound(ErrorCode.REPOSITORY_NOT_FOUND). The page resolves repo id asnumber | ServiceErrorand rendersRepoNotFoundonly for that code; other failures still throwServiceErrorException.Reviewed by Cursor Bugbot for commit 8323ed6. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit
New Features
Bug Fixes