{"record":{"id":"35141d177dc31fd0","repo":"github/github-mcp-server","slug":"owner-or-repo-not-specified","errorCode":null,"errorMessage":"owner or repo not specified","messagePattern":"owner or repo not specified","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/github/repository_resource_completions.go","lineNumber":155,"sourceCode":"\t\treturn values, errors.New(\"failed to get repositories\")\n\t}\n\t// filter repos based on argValue\n\tfor _, repo := range repos.Repositories {\n\t\tname := repo.GetName()\n\t\tif argValue == \"\" || strings.HasPrefix(name, argValue) {\n\t\t\tvalues = append(values, name)\n\t\t}\n\t}\n\n\treturn values, nil\n}\n\nfunc completeBranch(ctx context.Context, client *github.Client, resolved map[string]string, argValue string) ([]string, error) {\n\tvar values []string\n\towner := resolved[\"owner\"]\n\trepo := resolved[\"repo\"]\n\tif owner == \"\" || repo == \"\" {\n\t\treturn values, errors.New(\"owner or repo not specified\")\n\t}\n\tbranches, _, _ := client.Repositories.ListBranches(ctx, owner, repo, nil)\n\n\tfor _, branch := range branches {\n\t\tif argValue == \"\" || strings.HasPrefix(branch.GetName(), argValue) {\n\t\t\tvalues = append(values, branch.GetName())\n\t\t}\n\t}\n\tif len(values) > 100 {\n\t\tvalues = values[:100]\n\t}\n\treturn values, nil\n}\n\nfunc completeSHA(ctx context.Context, client *github.Client, resolved map[string]string, argValue string) ([]string, error) {\n\tvar values []string\n\towner := resolved[\"owner\"]\n\trepo := resolved[\"repo\"]","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/github/github-mcp-server/blob/0ea1f775a7c73eff1bd2e25904d01136756bbfe2/pkg/github/repository_resource_completions.go#L137-L173","documentation":"Thrown by the 'branch' argument completion handler (completeBranch) when the MCP completion request's resolved context lacks 'owner' or 'repo'. Completions are chained: the client resolves earlier URI segments (owner, then repo) and passes them via req.Params.Context.Arguments; if either is missing/empty, branch completion cannot proceed and errors immediately.","triggerScenarios":"A completion request for argument 'branch' where resolved[\"owner\"] == \"\" or resolved[\"repo\"] == \"\" — e.g. the client jumps straight to completing the branch segment of the repository resource URI without first resolving owner and repo, or passes an empty Arguments context.","commonSituations":"MCP client implementations that complete each URI segment independently without sending prior segment values; testing the completion handler directly with an empty resolved map; URI templates whose earlier parameters have different names than 'owner'/'repo'.","solutions":["Complete the URI segments in order: resolve 'owner' first, then 'repo', then request 'branch' completions with both values in the context arguments","On the client, always include previously resolved argument values in the completion request's context (req.Params.Context.Arguments)","If writing a custom handler, degrade gracefully: return empty values instead of an error when owner/repo are absent"],"exampleFix":"// before (handler errors out)\nif owner == \"\" || repo == \"\" {\n    return values, errors.New(\"owner or repo not specified\")\n}\n\n// after (degrade to empty completion instead of failing the MCP request)\nif owner == \"\" || repo == \"\" {\n    return nil, nil // no suggestions until owner/repo are resolved\n}","handlingStrategy":"validation","validationCode":"// Client-side: only request branch completions once owner+repo are resolved\nif ctxArgs[\"owner\"] == \"\" || ctxArgs[\"repo\"] == \"\" {\n    // resolve owner, then repo first; skip branch completion for now\n    return nil\n}\nreq := &mcp.CompleteRequest{Params: mcp.CompleteParams{\n    Ref: mcp.Ref{Type: \"ref/resource\", URI: repoTemplateURI},\n    Argument: mcp.Argument{Name: \"branch\", Value: partial},\n    Context: &mcp.Context{Arguments: ctxArgs}, // includes owner+repo\n}}","typeGuard":null,"tryCatchPattern":"// Server-side hardening: treat missing prerequisites as empty completion\nif owner == \"\" || repo == \"\" {\n    return &mcp.CompleteResult{Completion: mcp.CompletionResultDetails{Values: []string{}}}, nil\n}","preventionTips":["Always complete repository resource URI segments left-to-right","Include every previously resolved segment value in the completion request context","Keep URI template parameter names stable ('owner', 'repo') when customizing templates"],"tags":["completions","mcp","validation","argument-resolution"],"backgroundTag":null,"analyzedSha":"0ea1f775a7c73eff1bd2e25904d01136756bbfe2","analyzedAt":"2026-08-15T18:10:19.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}