{"record":{"id":"b419ac5dc8f16c89","repo":"sipeed/picoclaw","slug":"turn-profile-s-mode-has-unsupported-mode-q","errorCode":null,"errorMessage":"turn_profile.%s.mode has unsupported mode %q","messagePattern":"turn_profile\\.(.+?)\\.mode has unsupported mode %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/config/turn_profile.go","lineNumber":111,"sourceCode":"\t}\n\tif err := validateTurnProfileBlock(\"tools\", profile.Tools, true); err != nil {\n\t\treturn err\n\t}\n\treturn nil\n}\n\nfunc validateTurnProfileBlock(field string, block TurnProfileBlock, allowCustom bool) error {\n\tmode := block.Mode.Effective()\n\tswitch mode {\n\tcase TurnProfileModeDefault, TurnProfileModeOff:\n\t\treturn nil\n\tcase TurnProfileModeCustom:\n\t\tif allowCustom {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"turn_profile.%s.mode custom is not supported in this version\", field)\n\tdefault:\n\t\treturn fmt.Errorf(\"turn_profile.%s.mode has unsupported mode %q\", field, block.Mode)\n\t}\n}\n\nfunc cleanStringList(values []string) []string {\n\tif len(values) == 0 {\n\t\treturn nil\n\t}\n\tout := make([]string, 0, len(values))\n\tseen := make(map[string]struct{}, len(values))\n\tfor _, value := range values {\n\t\tvalue = strings.TrimSpace(value)\n\t\tif value == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tif _, ok := seen[value]; ok {\n\t\t\tcontinue\n\t\t}\n\t\tseen[value] = struct{}{}","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/sipeed/picoclaw/blob/49183d7e8daed0dba89ddbb6fcb60089401d9680/pkg/config/turn_profile.go#L93-L129","documentation":"Returned by validateTurnProfileBlock when a turn_profile block's mode is a string that matches none of default/off/custom (the switch default branch). The invalid value is echoed with %q so you can see exact whitespace/case issues. This is pure input validation on the mode field of any turn_profile block.","triggerScenarios":"`mode: on`, `mode: enabled`, `mode: CUSTOM`, `mode: \" off\"` (case/whitespace mismatch), or any typo like `mode: defualt` under any turn_profile block (history, system_prompt, skills, tools).","commonSituations":"Users coming from other tools write `on/off/enabled` instead of `default/off/custom`, or a stray character/space sneaks in during copy-paste. Case sensitivity surprises people (`Custom` vs `custom`).","solutions":["Set mode to one of the exact lowercase strings: default, off, or custom","Check the %q output in the error for hidden whitespace or wrong case and correct it","Pre-validate all mode values against the allowed set when generating configs programmatically (see typeGuard)"],"exampleFix":"# before\nturn_profile:\n  tools:\n    mode: enabled\n\n# after\nturn_profile:\n  tools:\n    mode: default","handlingStrategy":"type-guard","validationCode":"var allowedModes = map[string]bool{\"default\": true, \"off\": true, \"custom\": true}\nfunc modeAllowed(m string) bool { return allowedModes[strings.ToLower(strings.TrimSpace(m))] }","typeGuard":"func isValidTurnProfileMode(m string) bool {\n\tswitch strings.ToLower(strings.TrimSpace(m)) {\n\tcase \"default\", \"off\", \"custom\":\n\t\treturn true\n\t}\n\treturn false\n}","tryCatchPattern":"if err := cfg.Validate(); err != nil {\n\tvar modeErr *config.ValidationError // if defined; else match on \"unsupported mode\"\n\t_ = modeErr\n\treturn err\n}","preventionTips":["Use exact lowercase default|off|custom","Beware on/enabled/on/off habits from other tools","Let editors/CI validate against the mode enum"],"tags":["go","config","validation","turn-profile","typo"],"backgroundTag":null,"analyzedSha":"49183d7e8daed0dba89ddbb6fcb60089401d9680","analyzedAt":"2026-08-15T21:55:41.315Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}