Skip to content

feat: show not-found UI when an Ask GitHub repo doesn't exist#1432

Merged
brendan-kellam merged 3 commits into
mainfrom
brendan/askgh-repo-not-found
Jul 10, 2026
Merged

feat: show not-found UI when an Ask GitHub repo doesn't exist#1432
brendan-kellam merged 3 commits into
mainfrom
brendan/askgh-repo-not-found

Conversation

@brendan-kellam

@brendan-kellam brendan-kellam commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

When a repository doesn't exist on GitHub, the experimental Ask GitHub repo page (/askgh/[owner]/[repo]) previously threw a ServiceErrorException, 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 addGithubRepo action collapsed every non-OK response into a generic unexpectedError. So a dedicated not-found signal is plumbed through the stack.

Changes

Backend (packages/backend/src/)

  • errors.ts — added isNotFound(err) alongside the existing isUnauthorized/isForbidden/isGone, reusing the same getStatus helper.
  • api.tsexperimental_addGithubRepo wraps the octokit.rest.repos.get() call in try/catch: a 404 returns res.status(404), anything else re-throws (unchanged behavior).

Web (packages/web/src/)

  • lib/serviceError.ts — added a repositoryNotFound(repository) helper using the already-defined ErrorCode.REPOSITORY_NOT_FOUND (previously an unused enum member).
  • features/workerApi/actions.tsaddGithubRepo maps a 404 response to repositoryNotFound(...); all other failures stay unexpectedError.
  • app/(app)/askgh/[owner]/[repo]/page.tsx — returns the ServiceError from the repo-resolution block instead of throwing inside the IIFE; the page renders <RepoNotFound> when errorCode === REPOSITORY_NOT_FOUND, and only throws ServiceErrorException for everything else.
  • app/(app)/askgh/[owner]/[repo]/components/repoNotFound.tsx — new server component styled to match repoIndexedGuard.tsx.

Verification

  • tsc --noEmit clean on both @sourcebot/backend and @sourcebot/web (no new errors in changed files).
  • ESLint clean on all changed/new web files.
  • Backend errors.test.ts passes (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-repo path maps Octokit 404 to HTTP 404 via new isNotFound; addGithubRepo turns that into repositoryNotFound (ErrorCode.REPOSITORY_NOT_FOUND). The page resolves repo id as number | ServiceError and renders RepoNotFound only for that code; other failures still throw ServiceErrorException.

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

    • Added an experimental “Repository not found” page for Ask GitHub when a requested repository does not exist.
    • The page identifies the missing repository and provides a link back to the home page.
  • Bug Fixes

    • GitHub repository lookup failures now return a clear not-found message instead of a generic error.
    • Other unexpected errors continue to be handled normally.

brendan-kellam and others added 2 commits July 10, 2026 11:17
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>
@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e0c91c85-2df3-44be-b70c-12e1f2fa6967

📥 Commits

Reviewing files that changed from the base of the PR and between 4aec5d9 and 87a28aa.

📒 Files selected for processing (7)
  • CHANGELOG.md
  • packages/backend/src/api.ts
  • packages/backend/src/errors.ts
  • packages/web/src/app/(app)/askgh/[owner]/[repo]/components/repoNotFound.tsx
  • packages/web/src/app/(app)/askgh/[owner]/[repo]/page.tsx
  • packages/web/src/features/workerApi/actions.ts
  • packages/web/src/lib/serviceError.ts

Walkthrough

The 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.

Changes

Ask GitHub repository-not-found flow

Layer / File(s) Summary
Backend 404 detection
packages/backend/src/errors.ts, packages/backend/src/api.ts
GitHub 404 errors are identified and returned as HTTP 404 responses from the repository endpoint.
Typed repository error propagation
packages/web/src/lib/serviceError.ts, packages/web/src/features/workerApi/actions.ts
HTTP 404 responses become REPOSITORY_NOT_FOUND service errors containing the repository name.
Repository-not-found page
packages/web/src/app/(app)/askgh/[owner]/[repo]/page.tsx, packages/web/src/app/(app)/askgh/[owner]/[repo]/components/repoNotFound.tsx, CHANGELOG.md
The Ask GitHub page renders repository details, a not-found message, and a home link for missing repositories; the behavior is documented in the changelog.

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
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding a not-found UI for missing Ask GitHub repositories.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch brendan/askgh-repo-not-found

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

@brendan-kellam your pull request is missing a changelog!

@brendan-kellam brendan-kellam merged commit eeb9fd7 into main Jul 10, 2026
8 checks passed
@brendan-kellam brendan-kellam deleted the brendan/askgh-repo-not-found branch July 10, 2026 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant