{"record":{"id":"a615db3696104ce4","repo":"ipfs/kubo","slug":"priority-must-be-positive-d-0","errorCode":null,"errorMessage":"priority must be positive: %d <= 0","messagePattern":"priority must be positive: (.+?) <= 0","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/types.go","lineNumber":208,"sourceCode":"\t}\n}\n\nfunc (p *Priority) UnmarshalJSON(input []byte) error {\n\tswitch string(input) {\n\tcase \"null\", \"undefined\":\n\t\t*p = DefaultPriority\n\tcase \"false\":\n\t\t*p = Disabled\n\tcase \"true\":\n\t\treturn fmt.Errorf(\"'true' is not a valid priority\")\n\tdefault:\n\t\tvar priority int64\n\t\terr := json.Unmarshal(input, &priority)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif priority <= 0 {\n\t\t\treturn fmt.Errorf(\"priority must be positive: %d <= 0\", priority)\n\t\t}\n\t\t*p = Priority(priority)\n\t}\n\treturn nil\n}\n\nfunc (p Priority) String() string {\n\tif p > 0 {\n\t\treturn fmt.Sprintf(\"%d\", p)\n\t}\n\tswitch p {\n\tcase DefaultPriority:\n\t\treturn \"default\"\n\tcase Disabled:\n\t\treturn \"false\"\n\tdefault:\n\t\treturn fmt.Sprintf(\"<invalid priority %d>\", p)\n\t}","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/config/types.go#L190-L226","documentation":"The Priority type requires a strictly positive integer; UnmarshalJSON parses the JSON number and returns this error when the value is zero or negative. Priorities in kubo config are ranks where higher means more important, so 0 or negative values are meaningless and rejected.","triggerScenarios":"Unmarshaling {\"Priority\": 0} or {\"Priority\": -3} into a config Priority field.","commonSituations":"Hand-edited config.json with Priority set to 0 assuming it means 'default' or 'off'; scripts computing priorities that can produce zero or negatives; copying values from another config format.","solutions":["Set Priority to a positive integer (>= 1).","To disable, use the value \"false\" instead of 0.","Validate the JSON with `ipfs config --json` before writing config.json directly."],"exampleFix":"// before\n{\"Priority\": 0}\n// after\n{\"Priority\": 1}   // or \"false\" to disable","handlingStrategy":"validation","validationCode":"func checkPriority(n int64) error {\n    if n <= 0 {\n        return fmt.Errorf(\"priority must be > 0, got %d (use \\\"false\\\" to disable)\", n)\n    }\n    return nil\n}","typeGuard":"func isPositivePriority(v any) bool { n, ok := v.(float64); return ok && n > 0 }","tryCatchPattern":"if err := json.Unmarshal(data, &cfg); err != nil {\n    var perr *json.UnmarshalTypeError\n    if strings.Contains(err.Error(), \"priority must be positive\") {\n        // coerce to 1 or \"false\" and retry\n    }\n}","preventionTips":["Treat 0 as 'disabled' signal and emit \"false\" instead in config generators","Clamp computed priorities to >= 1 before writing config","Sanity-check generated config with `ipfs config show` in CI"],"tags":["config","json-parsing","validation"],"backgroundTag":"invalid-config-value","analyzedSha":"329838acdfafae224582930457efe80aa217afc0","analyzedAt":"2026-09-03T18:30:52.135Z","contentChangedAt":"2026-09-03T18:30:52.135Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}