{"record":{"id":"be431db8b0e6b9e9","repo":"chenhg5/cc-connect","slug":"value-must-be-0","errorCode":null,"errorMessage":"value must be >= 0","messagePattern":"value must be >= 0","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/engine.go","lineNumber":15155,"sourceCode":"\t\t\t\t\treturn e.displaySaveFunc(nil, &b, nil, nil, nil)\n\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tkey:    \"thinking_max_len\",\n\t\t\tdesc:   \"Max chars for thinking messages (0=no truncation)\",\n\t\t\tdescZh: \"思考消息最大长度 (0=不截断)\",\n\t\t\tgetFunc: func() string {\n\t\t\t\treturn fmt.Sprintf(\"%d\", e.display.ThinkingMaxLen)\n\t\t\t},\n\t\t\tsetFunc: func(v string) error {\n\t\t\t\tn, err := strconv.Atoi(v)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn fmt.Errorf(\"invalid integer: %s\", v)\n\t\t\t\t}\n\t\t\t\tif n < 0 {\n\t\t\t\t\treturn fmt.Errorf(\"value must be >= 0\")\n\t\t\t\t}\n\t\t\t\te.display.ThinkingMaxLen = n\n\t\t\t\tif e.displaySaveFunc != nil {\n\t\t\t\t\treturn e.displaySaveFunc(nil, nil, &n, nil, nil)\n\t\t\t\t}\n\t\t\t\treturn nil\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tkey:    \"tool_messages\",\n\t\t\tdesc:   \"Whether tool progress messages are shown (true/false)\",\n\t\t\tdescZh: \"是否显示工具进度消息 (true/false)\",\n\t\t\tgetFunc: func() string {\n\t\t\t\treturn fmt.Sprintf(\"%t\", e.display.ToolMessages)\n\t\t\t},\n\t\t\tsetFunc: func(v string) error {\n\t\t\t\tb, err := strconv.ParseBool(v)\n\t\t\t\tif err != nil {","sourceCodeStart":15137,"sourceCodeEnd":15173,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/core/engine.go#L15137-L15173","documentation":"The thinking-max-length setting must be non-negative: after a successful Atoi parse, a negative number is rejected because a negative truncation length is meaningless. This is an explicit range validation after the parse step.","triggerScenarios":"Setting thinking-max-length to any negative integer, e.g. -1 or -500.","commonSituations":"User intends 'unlimited' and tries -1; a computed/default value accidentally goes negative when derived from other config.","solutions":["Use 0 or a positive integer (0 typically means unlimited/no truncation — check the display logic).","Clamp derived values: if n < 0 { n = 0 } before calling the setter.","If 'unlimited' is desired, use the largest sensible positive value or the documented sentinel."],"exampleFix":"// before\nsetFunc(\"-1\") // error\n// after\nif n < 0 { n = 0 }\nsetFunc(strconv.Itoa(n))","handlingStrategy":"validation","validationCode":"n, _ := strconv.Atoi(v); if n < 0 { n = 0 } // clamp before applying","typeGuard":null,"tryCatchPattern":"if err := setThinkingMaxLen(v); err != nil {\n    if strings.Contains(err.Error(), \"value must be >= 0\") { /* clamp and retry with 0 */ }\n    return err\n}","preventionTips":["Never use negative numbers to mean 'unlimited'; use the documented sentinel (e.g. 0).","Clamp computed/derived lengths to >= 0 before saving.","Add range validation to any form that feeds this setting."],"tags":["configuration","validation","range-check"],"backgroundTag":"value-out-of-range","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}