fix(web): return graceful error for unknown search context#1362
fix(web): return graceful error for unknown search context#1362rachit367 wants to merge 2 commits into
Conversation
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
|
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 (3)
WalkthroughIn Search Context Error Handling
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
|
Caution Failed to replace (edit) comment. This is likely due to insufficient permissions or the comment being deleted. Error details |
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. Inpackages/web/src/features/search/parser.ts,onExpandSearchContextlooks the name up and, when it's missing, throws a plainError. The surroundingcatchonly mapsSyntaxErrorto aServiceErrorException; 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
ServiceErrorExceptionwith the existingSEARCH_CONTEXT_NOT_FOUNDerror code (HTTP 404) instead of a plainError.sew()already serializesServiceErrorExceptioninto 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:ServiceErrorExceptioncarryingSEARCH_CONTEXT_NOT_FOUND(previously a plain Error / crash);Both pass.
tsc --noEmitis clean for the web package.Summary by CodeRabbit
Bug Fixes
Tests