{"record":{"id":"6f8fc08a4a018945","repo":"abhigyanpatwari/GitNexus","slug":"no-indexed-repositories-run-gitnexus-analyze","errorCode":null,"errorMessage":"No indexed repositories. Run: gitnexus analyze","messagePattern":"No indexed repositories\\. Run: gitnexus analyze","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gitnexus/src/mcp/local/local-backend.ts","lineNumber":1725,"sourceCode":"      this.maybeWarnSiblingDrift(result).catch(() => {\n        /* best-effort; never throw from resolveRepo */\n      });\n      return this.applyBranchScope(result, branch);\n    }\n\n    // Miss — refresh registry and try once more (skip if already refreshed above)\n    if (!refreshedAfterAmbiguity) {\n      await this.refreshRepos();\n    }\n    const retried = this.resolveRepoFromCache(repoParam);\n    if (retried) {\n      this.maybeWarnSiblingDrift(retried).catch(() => {});\n      return this.applyBranchScope(retried, branch);\n    }\n\n    // Still no match — throw with helpful message\n    if (this.repos.size === 0) {\n      throw new Error('No indexed repositories. Run: gitnexus analyze');\n    }\n\n    // Build a disambiguated \"Available: …\" list (#829). When two handles\n    // share a name, annotate each colliding label with its path so the\n    // caller can actually pick the right one. Single-name entries render\n    // identically to pre-#829 output.\n    const nameCounts = new Map<string, number>();\n    for (const h of this.repos.values()) {\n      const key = h.name.toLowerCase();\n      nameCounts.set(key, (nameCounts.get(key) ?? 0) + 1);\n    }\n    const labels = [...this.repos.values()].map((h) =>\n      (nameCounts.get(h.name.toLowerCase()) ?? 0) > 1 ? `${h.name} (${h.repoPath})` : h.name,\n    );\n\n    if (repoParam) {\n      throw new Error(`Repository \"${repoParam}\" not found. Available: ${labels.join(', ')}`);\n    }","sourceCodeStart":1707,"sourceCodeEnd":1743,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/aac7515d2a8c50a1f8f923c6fb77218b333560d6/gitnexus/src/mcp/local/local-backend.ts#L1707-L1743","documentation":"During repo resolution, a cache miss triggers a registry refresh and one retry; if the retry still misses and the registry contains zero repos, LocalBackend throws this bootstrap hint instead of a not-found list. It means the GitNexus registry on this machine has never had a repo indexed (or points at an empty/alternate registry location).","triggerScenarios":"Calling any repo-scoped MCP tool (query, context, impact, ...) on a fresh install before any `gitnexus analyze` has run; after wiping the registry directory; or with GITNEXUS home/registry env overrides pointing at a different, empty location than the one you indexed into.","commonSituations":"First-time users wiring an MCP client before their first analyze; CI containers starting from a clean image each run; switching between global and npx installs that use different registry paths; env-var experiments leaving stale overrides set.","solutions":["Run `gitnexus analyze` in the repository you want indexed, then retry the tool call.","Confirm the repo appears: run the list_repos tool or `gitnexus status`.","Check that GITNEXUS-related home/registry env vars are unset or consistently set in both the indexing shell and the MCP client environment.","Restart the MCP server/session after indexing so it picks up the refreshed registry."],"exampleFix":"# before: no repo indexed yet\n$ gitnexus mcp call query '{\"search_query\": \"auth flow\"}'\n# → No indexed repositories. Run: gitnexus analyze\n\n# after: index first, then query\n$ cd ~/code/myrepo && gitnexus analyze\n$ gitnexus mcp call query '{\"search_query\": \"auth flow\", \"repo\": \"myrepo\"}'","handlingStrategy":"validation","validationCode":"// Preflight: ensure at least one repo is registered before repo-scoped calls\nconst repos = await client.callTool({ name: 'list_repos', arguments: {} });\nif (!repos?.repositories?.length) {\n  throw new Error('No repos indexed yet — run `gitnexus analyze` in the target repo first');\n}","typeGuard":null,"tryCatchPattern":"try {\n  return await client.callTool({ name: 'query', arguments: args });\n} catch (err) {\n  if (err instanceof Error && err.message.includes('No indexed repositories')) {\n    // bootstrap state, not a bug: index the repo, then retry once\n    await run('gitnexus analyze', { cwd: targetRepo });\n    return client.callTool({ name: 'query', arguments: { ...args, repo: targetRepoName } });\n  }\n  throw err;\n}","preventionTips":["Wire a list_repos health check into MCP client startup scripts.","Run `gitnexus analyze` as a setup step in CI images and dev bootstrap scripts.","Keep registry env overrides identical between the indexing shell and the MCP server environment.","Restart the MCP session after the first analyze so it sees the refreshed registry."],"tags":["mcp","registry","no-repos","analyze","bootstrap"],"backgroundTag":"empty-registry","analyzedSha":"aac7515d2a8c50a1f8f923c6fb77218b333560d6","analyzedAt":"2026-08-20T23:29:22.980Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}