{"record":{"id":"66bcbb9fddff6fbb","repo":"Tencent/WeKnora","slug":"slug-is-required","errorCode":null,"errorMessage":"slug is required","messagePattern":"slug is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/agent/tools/wiki_route_resolver.go","lineNumber":123,"sourceCode":"\t\t\tremaining = append(remaining, scope)\n\t\t}\n\t}\n\treturn remaining\n}\n\n// resolveUniqueWikiPage is the shared mutation/issue routing boundary. It\n// checks every allowed KB (cached provenance only affects order) and refuses\n// ambiguous slugs instead of silently mutating the first KB.\nfunc resolveUniqueWikiPage(\n\tctx context.Context,\n\tservice interfaces.WikiPageService,\n\tslug string,\n\tkbIDs []string,\n\troutes *WikiRouteResolver,\n) (*types.WikiPage, string, error) {\n\tslug = strings.TrimSpace(slug)\n\tif slug == \"\" {\n\t\treturn nil, \"\", fmt.Errorf(\"slug is required\")\n\t}\n\tscopes := NewWikiScopesFromKBIDs(kbIDs)\n\tpreferred := routes.scopesForSlug(slug, scopes)\n\tordered := append(append([]WikiScope(nil), preferred...), scopesOutsideKBs(scopes, preferred)...)\n\ttype hit struct {\n\t\tpage *types.WikiPage\n\t\tkbID string\n\t}\n\tvar hits []hit\n\tfor _, scope := range ordered {\n\t\tpage, err := service.GetPageBySlug(ctx, scope.KnowledgeBaseID, slug)\n\t\tif err != nil {\n\t\t\tif errors.Is(err, repository.ErrWikiPageNotFound) {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\treturn nil, \"\", fmt.Errorf(\n\t\t\t\t\"failed to resolve wiki page %s in knowledge base %s: %w\",\n\t\t\t\tslug, scope.KnowledgeBaseID, err,","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/agent/tools/wiki_route_resolver.go#L105-L141","documentation":"resolveUniqueWikiPage validates its slug argument before attempting any per-scope lookups. An empty (or whitespace-only) slug cannot identify a wiki page, so it fails fast with this error instead of issuing doomed GetPageBySlug calls. It is an argument-validation error guarding the resolver's contract.","triggerScenarios":"Calling resolveUniqueWikiPage (via the wiki tool's Execute, e.g. wiki read/update/delete) with slug \"\" or a slug consisting only of whitespace, typically because the LLM omitted the slug parameter or upstream parsing produced an empty value.","commonSituations":"Model calling the wiki tool without filling the slug argument; a page title never converted to a slug upstream; tool schema allowing the field to be omitted.","solutions":["Ensure the tool schema marks slug as required so the model always supplies it","Trim/validate the slug in the tool's argument parsing and reject the call early with a clear tool error","Have the caller list pages or search by title when the slug is unknown instead of passing an empty string"],"exampleFix":"// before\nslug := args[\"slug\"]\npage, kbID, err := resolveUniqueWikiPage(ctx, slug, kbIDs, routes)\n// after\nslug := strings.TrimSpace(args[\"slug\"])\nif slug == \"\" { return &types.ToolResult{Success: false, Error: \"slug is required\"}, nil }\npage, kbID, err := resolveUniqueWikiPage(ctx, slug, kbIDs, routes)","handlingStrategy":"validation","validationCode":"slug := strings.TrimSpace(args[\"slug\"])\nif slug == \"\" {\n    return &types.ToolResult{Success: false, Error: \"slug is required\"}, nil\n}","typeGuard":"func validSlug(s string) bool { return strings.TrimSpace(s) != \"\" }","tryCatchPattern":"page, kbID, err := resolveUniqueWikiPage(ctx, slug, kbIDs, routes)\nif err != nil && strings.Contains(err.Error(), \"slug is required\") {\n    // prompt model/user for the slug; do not retry with same args\n}","preventionTips":["Mark slug as required in the tool JSON schema","Trim inputs before passing to the resolver","Fall back to a title search when slug is unknown","Unit-test the tool with an omitted slug argument"],"tags":["go","validation","wiki","argument-error"],"backgroundTag":"missing-required-argument","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}