{"record":{"id":"131eafa7f0212d8b","repo":"abhigyanpatwari/GitNexus","slug":"specify-an-explicit-repo-because-multiple-reposito","errorCode":null,"errorMessage":"Specify an explicit repo because multiple repositories are allowed.","messagePattern":"Specify an explicit repo because multiple repositories are allowed\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gitnexus/src/mcp/repository-policy.ts","lineNumber":151,"sourceCode":"  }\n\n  private repoForArgs(args: Record<string, unknown> | undefined): ResolvedRepository | undefined {\n    const explicit = args?.repo;\n    if (explicit !== undefined) {\n      if (typeof explicit !== 'string') throw unavailableRepositoryError();\n      if (explicit.trim().startsWith('@')) {\n        if (this.restricted) {\n          throw new Error('Group routing is unavailable when an MCP repository allowlist is set.');\n        }\n        return undefined;\n      }\n      return this.resolveRuntimeRepo(explicit);\n    }\n\n    if (this.defaultRepo) return this.defaultRepo;\n    if (this.restricted && this.allowed.length === 1) return this.allowed[0];\n    if (this.restricted && this.allowed.length > 1) {\n      throw new Error('Specify an explicit repo because multiple repositories are allowed.');\n    }\n    return undefined;\n  }\n\n  private normalizeToolArgs(\n    args: Record<string, unknown> | undefined,\n  ): Record<string, unknown> | undefined {\n    if (!this.configured) return args;\n    if (!this.restricted && args?.repo !== undefined) return args;\n    const selected = this.repoForArgs(args);\n    if (!selected) return args;\n    return { ...(args ?? {}), repo: selected.path };\n  }\n\n  private async listAllowedRepos(backend: LocalBackend): Promise<RepoListing[]> {\n    const current = await backend.listRepos();\n    if (!this.restricted) return current;\n    return current","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/52924ef12c2290ceee4612526a828ec4cdf2047f/gitnexus/src/mcp/repository-policy.ts#L133-L169","documentation":"Thrown by McpRepositoryPolicy.repoForArgs when a repository allowlist with more than one entry is configured, the call provides no explicit repo argument, and no GITNEXUS_MCP_DEFAULT_REPO is set. With multiple allowed repositories the server cannot pick one for you, so it refuses the ambiguous call instead of guessing.","triggerScenarios":"GITNEXUS_MCP_ALLOWED_REPOS='frontend,backend' (2+ entries) and no GITNEXUS_MCP_DEFAULT_REPO, then calling a tool with no repo in the arguments — e.g. { search_query: 'auth' } only. A single-entry allowlist auto-selects that repo and does not throw.","commonSituations":"Growing a deployment from one repo to two: the previously optional repo argument becomes mandatory overnight and every cached agent prompt starts failing. Clients that omit repo because 'the server knows its repo' break when a second repo is indexed and allowed.","solutions":["Include an explicit repo in every tool call: { search_query: 'auth', repo: 'frontend' }.","Set GITNEXUS_MCP_DEFAULT_REPO to one of the allowed repositories to restore repo-optional calls.","If only one repo should be served, reduce GITNEXUS_MCP_ALLOWED_REPOS to that single entry — it is then auto-selected."],"exampleFix":"# before\nawait client.callTool({ name: 'query', arguments: { search_query: 'auth' } });\n\n# after\nawait client.callTool({ name: 'query', arguments: { search_query: 'auth', repo: 'frontend' } });\n# or server env: GITNEXUS_MCP_DEFAULT_REPO=frontend","handlingStrategy":"validation","validationCode":"// Before calling tools when an allowlist may be set:\nif (allowlistCount > 1 && !defaultRepoConfigured && args.repo === undefined) {\n  throw new Error('Multiple repos allowed and no default — pass an explicit repo argument.');\n}","typeGuard":"const hasExplicitRepo = (args: Record<string, unknown> | undefined): boolean =>\n  typeof args?.repo === 'string' && args.repo.trim().length > 0;","tryCatchPattern":"try {\n  await client.callTool({ name: 'query', arguments });\n} catch (e) {\n  if (e instanceof Error && e.message.includes('Specify an explicit repo')) {\n    const repo = await promptUserForRepo(); // or read gitnexus://repos and pick\n    return client.callTool({ name: 'query', arguments: { ...arguments, repo } });\n  }\n  throw e;\n}","preventionTips":["Always include an explicit repo argument when you control the client — it works in every policy mode.","When adding a second repo to an allowlist, set GITNEXUS_MCP_DEFAULT_REPO or update all callers the same day.","On connect, read gitnexus://repos so you can offer a concrete choice instead of failing."],"tags":["mcp","allowlist","default-repository","missing-argument"],"backgroundTag":"missing-required-argument","analyzedSha":"52924ef12c2290ceee4612526a828ec4cdf2047f","analyzedAt":"2026-08-20T23:29:22.980Z","contentChangedAt":"2026-08-20T23:29:22.980Z","schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}