{"record":{"id":"54dc449757f8de3b","repo":"gastownhall/beads","slug":"hierarchy-max-depth-must-be-at-least-1-got-d","errorCode":null,"errorMessage":"hierarchy.max-depth must be at least 1, got %d","messagePattern":"hierarchy\\.max-depth must be at least 1, got (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/config/yaml_config.go","lineNumber":886,"sourceCode":"\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)\n\t\t}\n\tcase \"prime.max-memories\":\n\t\tn, err := strconv.Atoi(value)","sourceCodeStart":868,"sourceCodeEnd":904,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/config/yaml_config.go#L868-L904","documentation":"validateYamlConfigValue rejects a hierarchy.max-depth that parses as an integer but is less than 1 (GH#995 requires depth >= 1). The %d shows the parsed number. bd throws it because a zero or negative depth would make hierarchy traversal meaningless or infinite-loop-prone.","triggerScenarios":"SetYamlConfig-family calls with key \"hierarchy.max-depth\" and numeric values like \"0\", \"-1\", \"-100\".","commonSituations":"Trying to 'disable' hierarchy by setting 0 instead of unsetting; a script decrementing the value below 1; fat-fingering a negative number.","solutions":["Set at least 1: bd config set hierarchy.max-depth 1","To disable hierarchy traversal, comment out the key with UnsetYamlConfig instead of setting 0","Clamp computed/scripted values: if v < 1 { v = 1 } before calling SetYamlConfig","Review existing config.yaml for a bad stored value and correct it"],"exampleFix":"// before\nSetYamlConfig(\"hierarchy.max-depth\", \"0\") // error: must be at least 1\n// after\nSetYamlConfig(\"hierarchy.max-depth\", \"1\") // or UnsetYamlConfig(\"hierarchy.max-depth\")","handlingStrategy":"validation","validationCode":"n, err := strconv.Atoi(v)\nif err != nil || n < 1 {\n    return fmt.Errorf(\"hierarchy.max-depth must be >= 1, got %q\", v)\n}","typeGuard":"func isValidMaxDepth(s string) bool {\n    n, err := strconv.Atoi(s)\n    return err == nil && n >= 1\n}","tryCatchPattern":"if err := SetYamlConfig(\"hierarchy.max-depth\", v); err != nil {\n    if strings.Contains(err.Error(), \"must be at least 1\") {\n        // clamp to 1 or unset the key instead\n    }\n    return err\n}","preventionTips":["Clamp computed values to >= 1 before setting","Use UnsetYamlConfig (not 0) to disable hierarchy limits","Add a range check to any script that derives the depth value"],"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"}