{"record":{"id":"a5821a34cbccde49","repo":"gastownhall/beads","slug":"hierarchy-max-depth-must-be-a-positive-integer-go","errorCode":null,"errorMessage":"hierarchy.max-depth must be a positive integer, got %q","messagePattern":"hierarchy\\.max-depth must be a positive integer, got %q","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/config/yaml_config.go","lineNumber":883,"sourceCode":"\tif len(s) < 2 {\n\t\treturn false\n\t}\n\tsuffix := s[len(s)-1]\n\tif suffix != 's' && suffix != 'm' && suffix != 'h' {\n\t\treturn false\n\t}\n\treturn isNumeric(s[:len(s)-1])\n}\n\n// validateYamlConfigValue validates a configuration value before setting.\n// Returns an error if the value is invalid for the given key.\nfunc validateYamlConfigValue(key, value string) error {\n\tswitch key {\n\tcase \"hierarchy.max-depth\":\n\t\t// Must be a positive integer >= 1 (GH#995)\n\t\tdepth, err := strconv.Atoi(value)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"hierarchy.max-depth must be a positive integer, got %q\", value)\n\t\t}\n\t\tif depth < 1 {\n\t\t\treturn fmt.Errorf(\"hierarchy.max-depth must be at least 1, got %d\", depth)\n\t\t}\n\tcase \"dolt.shared-server\":\n\t\tlower := strings.ToLower(value)\n\t\tif lower != \"true\" && lower != \"false\" {\n\t\t\treturn fmt.Errorf(\"dolt.shared-server must be \\\"true\\\" or \\\"false\\\", got %q\", value)\n\t\t}\n\tcase \"dolt.debug\":\n\t\tlower := strings.ToLower(value)\n\t\tif lower != \"true\" && lower != \"false\" {\n\t\t\treturn fmt.Errorf(\"dolt.debug must be \\\"true\\\" or \\\"false\\\", got %q\", value)\n\t\t}\n\tcase \"dolt.mode\":\n\t\tlower := strings.ToLower(value)\n\t\tif lower != \"server\" && lower != \"embedded\" {\n\t\t\treturn fmt.Errorf(\"dolt.mode must be \\\"server\\\" or \\\"embedded\\\", got %q\", value)","sourceCodeStart":865,"sourceCodeEnd":901,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/config/yaml_config.go#L865-L901","documentation":"validateYamlConfigValue rejects a hierarchy.max-depth value that is not parseable as an integer (GH#995). The %q shows the offending string exactly as provided. bd throws it to prevent storing a non-numeric depth that downstream hierarchy traversal would choke on.","triggerScenarios":"SetYamlConfig / SetYamlConfigInDir / SetUserYamlConfig called with key \"hierarchy.max-depth\" and a value like \"five\", \"\", \"3.5\", \"1e3\", or \" 3\" (strconv.Atoi fails).","commonSituations":"Typing 'bd config set hierarchy.max-depth ten'; copy-pasting a float or quoted value; shell passing extra whitespace or units like '10 levels'.","solutions":["Set a plain positive integer, e.g. bd config set hierarchy.max-depth 5","Strip quotes, whitespace, units, and decimals from the value before setting","If scripted, validate with a shell/Go integer check before calling SetYamlConfig","Use UnsetYamlConfig to remove a bad existing value and re-set it correctly"],"exampleFix":"// before\nSetYamlConfig(\"hierarchy.max-depth\", \"ten\") // error\n// after\nSetYamlConfig(\"hierarchy.max-depth\", \"10\")","handlingStrategy":"validation","validationCode":"v := \"ten\" // value to set\nif _, err := strconv.Atoi(v); err != nil {\n    return fmt.Errorf(\"hierarchy.max-depth must be an integer, got %q\", v)\n}","typeGuard":"func isPositiveIntString(s string) bool {\n    n, err := strconv.Atoi(s)\n    return err == nil\n}","tryCatchPattern":"if err := SetYamlConfig(\"hierarchy.max-depth\", v); err != nil {\n    if strings.Contains(err.Error(), \"must be a positive integer\") {\n        // re-prompt or coerce to an integer, then retry\n    }\n    return err\n}","preventionTips":["Pass plain integers without quotes, units, decimals, or whitespace","Validate user/flag input with strconv.Atoi before calling config set","Remember Go string values: set \"10\", not 10-as-text-with-noise"],"tags":["config","validation","go"],"backgroundTag":"config-value-validation-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}