{"record":{"id":"11dab2c4b5206bdb","repo":"Tencent/WeKnora","slug":"invalid-follow-up-suggestion-category-q","errorCode":null,"errorMessage":"invalid follow-up suggestion category %q","messagePattern":"invalid follow-up suggestion category %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/types/custom_agent.go","lineNumber":408,"sourceCode":"\t}\n\tif !oneOf(c.FollowUps.Mode, SuggestionModeGenerated, SuggestionModeKnowledge, SuggestionModeHybrid) {\n\t\treturn fmt.Errorf(\"invalid follow-up suggestion mode %q\", c.FollowUps.Mode)\n\t}\n\tfor i, item := range c.Starters.Items {\n\t\ttrimmed := strings.TrimSpace(item)\n\t\tif trimmed == \"\" {\n\t\t\treturn fmt.Errorf(\"starter suggestion %d cannot be empty\", i+1)\n\t\t}\n\t\tif len([]rune(trimmed)) > 200 {\n\t\t\treturn fmt.Errorf(\"starter suggestion %d exceeds 200 characters\", i+1)\n\t\t}\n\t}\n\tif len([]rune(strings.TrimSpace(c.FollowUps.AdditionalInstruction))) > 2000 {\n\t\treturn fmt.Errorf(\"follow-up additional_instruction exceeds 2000 characters\")\n\t}\n\tfor _, category := range c.FollowUps.Categories {\n\t\tif !oneOf(category, SuggestionCategoryClarify, SuggestionCategoryDeepen, SuggestionCategoryAction) {\n\t\t\treturn fmt.Errorf(\"invalid follow-up suggestion category %q\", category)\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc oneOf(value string, allowed ...string) bool {\n\tfor _, candidate := range allowed {\n\t\tif value == candidate {\n\t\t\treturn true\n\t\t}\n\t}\n\treturn false\n}\n\n// ResolveChatParserEngine returns the agent-configured parser engine for a\n// chat attachment file type, or the type-level default when no rule matches.\n// Mirrors ParserEngineConfig.ResolveChatParserEngine.\nfunc (c *CustomAgentConfig) ResolveChatParserEngine(fileType string) string {","sourceCodeStart":390,"sourceCodeEnd":426,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/types/custom_agent.go#L390-L426","documentation":"This error is thrown by the follow-up suggestion config validator (Validate on the custom agent config) when a follow-up suggestion category is not one of the three allowed values: clarify, deepen, action. The library restricts FollowUps.Categories to this fixed enum so downstream suggestion rendering remains well-defined.","triggerScenarios":"Calling the custom agent config validation (e.g. via agent create/update APIs) with c.FollowUps.Categories containing a value other than \"clarify\", \"deepen\", or \"action\" — including empty strings, typos, or old/renamed category values.","commonSituations":"Hand-written agent config JSON with a misspelled category (e.g. \"summary\", \"followup\"), categories migrated from an older schema version that used different names, or programmatic generation injecting raw user input as a category.","solutions":["Replace the offending category value with one of the allowed values: clarify, deepen, action","Check exact spelling and case of each entry in follow_ups.categories","If the old category no longer exists, map it to the closest allowed category or remove it","Pre-validate categories against the SuggestionCategory constants before submitting the config"],"exampleFix":"// before\nc.FollowUps.Categories = []string{\"summarize\", \"clarify\"}\n// after\nc.FollowUps.Categories = []string{\"clarify\", \"deepen\"}","handlingStrategy":"validation","validationCode":"var validCategories = map[string]bool{\"clarify\": true, \"deepen\": true, \"action\": true}\nfunc categoriesValid(cats []string) bool {\n    for _, c := range cats { if !validCategories[c] { return false } }\n    return true\n}","typeGuard":"func isSuggestionCategory(s string) bool {\n    return s == SuggestionCategoryClarify || s == SuggestionCategoryDeepen || s == SuggestionCategoryAction\n}","tryCatchPattern":"if err := cfg.Validate(); err != nil {\n    var msg string\n    if _, err := fmt.Sscanf(err.Error(), \"invalid follow-up suggestion category %q\", &msg); err == nil {\n        // surface msg to the user as an invalid category\n    }\n}","preventionTips":["Define the categories as a typed enum or constants and never accept raw strings","Validate config at the UI/boundary before submission","Keep a unit test validating every category value used in shipped configs"],"tags":["validation","config","go"],"backgroundTag":"invalid-enum-value","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}