{"record":{"id":"32517e757cb3b938","repo":"abhigyanpatwari/GitNexus","slug":"repository-not-found","errorCode":null,"errorMessage":"Repository not found","messagePattern":"Repository not found","errorType":"http","errorClass":null,"httpStatus":404,"severity":"error","filePath":"gitnexus/src/server/api.ts","lineNumber":664,"sourceCode":"  resolveRepo: (repoName?: string) => Promise<{ storagePath: string } | undefined>,\n): Promise<void> => {\n  try {\n    const cypher = req.body.cypher as string;\n    if (!cypher) {\n      res.status(400).json({ error: 'Missing \"cypher\" in request body' });\n      return;\n    }\n    const queryParams = req.body.params;\n    if (queryParams !== undefined && !isValidQueryParams(queryParams)) {\n      res.status(400).json({\n        error: '\"params\" must be a plain object with scalar values (string/number/boolean/null)',\n      });\n      return;\n    }\n\n    const entry = await resolveRepo(requestedRepo(req));\n    if (!entry) {\n      res.status(404).json({ error: 'Repository not found' });\n      return;\n    }\n    const lbugPath = path.join(entry.storagePath, 'lbug');\n    const result = await withLbugDb(lbugPath, () => executePrepared(cypher, queryParams ?? {}), {\n      readOnly: true,\n    });\n    res.json({ result });\n  } catch (err: any) {\n    if (isReadOnlyDbError(err)) {\n      res.status(403).json({ error: 'Write queries are not allowed via the HTTP API' });\n      return;\n    }\n    res.status(500).json({ error: err.message || 'Query failed' });\n  }\n};\n\n/**\n * Validate the optional `token` field of POST /api/analyze. Returns an","sourceCodeStart":646,"sourceCodeEnd":682,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/aac7515d2a8c50a1f8f923c6fb77218b333560d6/gitnexus/src/server/api.ts#L646-L682","documentation":"HTTP 404 from POST /api/query when resolveRepo(requestedRepo(req)) returns undefined — no repository could be resolved for the request. Resolution uses the ?repo= parameter when supplied, otherwise the server's default repo. A repository becomes resolvable only after gitnexus analyze has registered it; this 404 fires before any Cypher is executed.","triggerScenarios":"POST /api/query with ?repo=typo or a name that differs from the registered name; no ?repo= given while the serve process was started from a directory whose repo was never indexed; querying right after wiping the index storage; the serve process defaulting to a different repo than the one you indexed.","commonSituations":"Fresh clone: developer starts gitnexus serve before running analyze; name mismatches (GitHub org prefix, .git suffix, case) between what the client sends and the registry entry; switching serve between repos and stale client ?repo= values; CI environments where the index lives in a different storage path.","solutions":["Run `gitnexus analyze` in the repository so it is registered, then retry","List what is actually available via GET /api/repos and use the exact registered name in ?repo=","If you intended the default repo, start serve from the repo root (or pass the repo explicitly) so default resolution matches","For upload-based repos, wait until the analysis job completes — the repo resolves only once registered"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Resolve the repo name against the registry before querying.\nconst reposRes = await fetch(`${base}/api/repos`);\nconst repos: { name: string }[] = await reposRes.json();\nconst match = repos.find((r) => r.name === requestedName);\nif (!match) throw new Error(`repo not registered — run gitnexus analyze. Available: ${repos.map((r) => r.name).join(', ')}`);","typeGuard":null,"tryCatchPattern":"const res = await postQuery(cypher, requestedName);\nif (res.status === 404 && (await res.json()).error === 'Repository not found') {\n  const choices = await listRepos();\n  promptRepoSelection(choices); // or trigger analyze in a guided flow\n}","preventionTips":["Run gitnexus analyze before pointing query clients at serve","Always pass an explicit ?repo= with the exact registered name","Cache the /api/repos list at connect time and validate names against it"],"tags":["http-404","api","repository","indexing"],"backgroundTag":"repository-not-found","analyzedSha":"aac7515d2a8c50a1f8f923c6fb77218b333560d6","analyzedAt":"2026-08-20T23:29:22.980Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}