{"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":1941,"sourceCode":"    };\n    // Record the assignment so subsequent entries in the same refresh see this\n    // id as taken (the function owns its own invariant).\n    const claim = (id: string): string => {\n      assigned.set(id, resolved);\n      return id;\n    };\n\n    if (free(base)) return claim(base);\n\n    // Legacy suffix from the *raw* path — kept byte-for-byte so the first\n    // colliding duplicate keeps the id it had before #2054 (#1658 tier).\n    const legacy = `${base}-${Buffer.from(repoPath)\n      .toString('base64url')\n      .slice(0, REPO_ID_HASH_LENGTH)\n      .toLowerCase()}`;\n    if (free(legacy)) return claim(legacy);\n\n    // Real collision — hash the resolved path. Lowercase hex survives the\n    // `paramLower` lookup in resolveRepoFromCache.\n    const digest = createHash('sha256').update(resolved).digest('hex');\n    for (let len = REPO_ID_HASH_LENGTH; len <= digest.length; len++) {\n      const candidate = `${base}-${digest.slice(0, len)}`;\n      if (free(candidate)) return claim(candidate);\n    }\n\n    // Two distinct resolved paths sharing a full SHA-256 digest is a hash\n    // break, not a runtime condition — fail loudly rather than silently\n    // overwrite a different repo's handle (#2054 invariant).\n    throw new Error(\n      `GitNexus internal: unable to assign a unique repo id for \"${name}\" at ${repoPath}`,\n    );\n  }\n\n  // ─── Repo Resolution ─────────────────────────────────────────────\n\n  /**","sourceCodeStart":1923,"sourceCodeEnd":1959,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/ac9a4e9abd8fd3058c070b72c23402a4f887929a/gitnexus/src/mcp/local/local-backend.ts#L1923-L1959","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":"ac9a4e9abd8fd3058c070b72c23402a4f887929a","analyzedAt":"2026-08-20T23:29:22.980Z","contentChangedAt":"2026-08-20T23:29:22.980Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}