Skip to content

Commit 5efaf29

Browse files
committed
merge main
2 parents a1cf62d + cf6fc3d commit 5efaf29

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313

1414
### Fixes
1515
- Fix autocomplete when repo includes default port [#762](https://github.com/sourcebot-dev/sourcebot/pull/762)
16+
- Fixed "Repository not found for file: x" error when searching in orphaned shards. [#761](https://github.com/sourcebot-dev/sourcebot/pull/761)
1617

1718
## [4.10.12] - 2026-01-16
1819

packages/web/src/features/search/zoektSearcher.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { createLogger, env } from "@sourcebot/shared";
1717
import path from 'path';
1818
import { isBranchQuery, QueryIR, someInQueryIR } from './ir';
1919
import { RepositoryInfo, SearchResponse, SearchResultFile, SearchStats, SourceRange, StreamedSearchErrorResponse, StreamedSearchResponse } from "./types";
20+
import { captureEvent } from "@/lib/posthog";
2021

2122
const logger = createLogger("zoekt-searcher");
2223

@@ -383,9 +384,17 @@ const transformZoektSearchResponse = async (response: ZoektGrpcSearchResponse, r
383384
const repoId = getRepoIdForFile(file);
384385
const repo = reposMapCache.get(repoId);
385386

386-
// This should never happen.
387+
// This can happen when a shard exists for a repository that does not exist in the database.
388+
// In this case, issue a error message and skip the file.
389+
// @see: https://github.com/sourcebot-dev/sourcebot/issues/669
387390
if (!repo) {
388-
throw new Error(`Repository not found for file: ${file.file_name}`);
391+
const errorMessage = `Unable to find repository "${file.repository}" in database for file "${file.file_name}". This can happen when a search shard exists for a repository that does not exist in the database. See https://github.com/sourcebot-dev/sourcebot/issues/669 for more details. Skipping file...`;
392+
393+
logger.error(errorMessage);
394+
Sentry.captureMessage(errorMessage);
395+
captureEvent('wa_repo_not_found_for_zoekt_file', {});
396+
397+
return undefined;
389398
}
390399

391400
// @todo: address "file_name might not be a valid UTF-8 string" warning.

packages/web/src/lib/posthogEvents.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ export type PosthogEventMap = {
185185
durationMs: number,
186186
},
187187
//////////////////////////////////////////////////////////////////
188+
wa_repo_not_found_for_zoekt_file: {},
189+
//////////////////////////////////////////////////////////////////
188190
api_code_search_request: {
189191
source: string;
190192
type: 'streamed' | 'blocking';

0 commit comments

Comments
 (0)