GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(web): return graceful error for unknown search context by rachit367 · Pull Request #1362 · sourcebot-dev/sourcebot

Conversation

@rachit367

@rachit367 rachit367 commented Jun 23, 2026 •
edited by coderabbitai Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Fixes #1312

Problem

Searching with context:<value> (e.g. Helpers context:0) crashes the request when no search context with that name exists.

context: resolves a named search context. In packages/web/src/features/search/parser.ts, onExpandSearchContext looks the name up and, when it's missing, throws a plain Error. The surrounding catch only maps SyntaxError to a ServiceErrorException; every other error is re-thrown as-is, so this one escapes the search action and surfaces as a server crash instead of a clean error.

Fix

Throw a ServiceErrorException with the existing SEARCH_CONTEXT_NOT_FOUND error code (HTTP 404) instead of a plain Error. sew() already serializes ServiceErrorException into a proper service-error response, so the user now gets a clear "Search context not found" message rather than a crashed request. All imports needed were already present.

Tests

Added parser.test.ts:

  • unknown context → rejects with a ServiceErrorException carrying SEARCH_CONTEXT_NOT_FOUND (previously a plain Error / crash);
  • existing context → expands into its repo set.

Both pass. tsc --noEmit is clean for the web package.

Summary by CodeRabbit

  • Bug Fixes

    • Searching with a context value that references a non-existent search context no longer crashes. It now returns a graceful “not found” error response with appropriate error details.
  • Tests

    • Added coverage verifying correct errors for missing search contexts and proper expansion of valid contexts into associated repositories.

Note

Low Risk
Localized change to search query parsing error handling with tests; no auth, data, or broad API behavior changes.

Overview
When a search query uses context: with a name that does not exist, the parser now raises ServiceErrorException with SEARCH_CONTEXT_NOT_FOUND (404) instead of a plain Error, so the search path returns a structured “not found” response instead of crashing.

parser.test.ts adds coverage for the missing-context error and for successful context expansion into repo names.

Reviewed by Cursor Bugbot for commit ed5fb68. Bugbot is set up for automated code reviews on this repo. Configure here.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@rachit367
fix(web): return graceful error for unknown search context
7fdbbfe
context:<value> resolves a named search context. When the context did
not exist, onExpandSearchContext threw a plain Error, which is not caught
by the SyntaxError-only handler and crashed the request. Throw a
ServiceErrorException with SEARCH_CONTEXT_NOT_FOUND so it returns a clean
404 instead.

Fixes sourcebot-dev#1312
@coderabbitai

coderabbitai Bot commented Jun 23, 2026 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

onExpandSearchContext now throws a structured ServiceErrorException for missing search contexts instead of a generic error. Tests cover missing-context handling and repository expansion. CHANGELOG.md records the fix.

Changes

Search Context Error Handling

Layer / File(s) Summary
Structured missing-context error
packages/web/src/features/search/parser.ts
onExpandSearchContext throws ServiceErrorException with HTTP 404, SEARCH_CONTEXT_NOT_FOUND, and the missing context name.
Parser tests and changelog
packages/web/src/features/search/parser.test.ts, CHANGELOG.md
Tests cover the rejected missing-context lookup and successful repository expansion. The changelog documents the fixed crash path.

Estimated code review effort: 2 (Simple) | ~8 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the fix for unknown search context errors.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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
  • X
  • Mastodon
  • Reddit
  • LinkedIn

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@rachit367
docs: add changelog entry for search context crash fix
2f09e68
@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Caution

Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted.

Error details
{}
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

brendan-kellam added 2 commits June 25, 2026 10:13
@brendan-kellam
Merge branch 'main' into rachit367/fix-search-context-crash
e0ac451
@brendan-kellam
Merge branch 'main' into rachit367/fix-search-context-crash
ffc24c7
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@brendan-kellam
Fix changelog
ed5fb68
brendan-kellam
brendan-kellam approved these changes Aug 4, 2026
View reviewed changes
@brendan-kellam
brendan-kellam merged commit a6c7695 into sourcebot-dev:main Aug 4, 2026
9 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot mentioned this pull request Aug 4, 2026
Sourcebot Roadmap 🚀 #459
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@brendan-kellam brendan-kellam brendan-kellam approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[bug] it is not possible to use context:0 ... N

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@rachit367 @brendan-kellam
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.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.