{"record":{"id":"94dd9dbf12590c05","repo":"ipfs/kubo","slug":"true-is-not-a-valid-priority","errorCode":null,"errorMessage":"'true' is not a valid priority","messagePattern":"'true' is not a valid priority","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"config/types.go","lineNumber":200,"sourceCode":"\t// <= 0 == special\n\tswitch p {\n\tcase DefaultPriority:\n\t\treturn json.Marshal(nil)\n\tcase Disabled:\n\t\treturn json.Marshal(false)\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"invalid priority value: %d\", p)\n\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}","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/config/types.go#L182-L218","documentation":"config/types.go's Priority type implements json.UnmarshalJSON and accepts \"true\" only as the literal string meaning enabled-with-default-priority, a bare JSON boolean true, or an integer. The bare JSON literal `true` (unquoted boolean) is explicitly rejected because a priority must be either disabled (false) or carry a positive numeric value; there is no defined default numeric priority for the bare true literal.","triggerScenarios":"Unmarshaling JSON config such as {\"priority\": true} (unquoted boolean true) into a Priority field via json.Unmarshal or `ipfs config --json`.","commonSituations":"Users editing config.json by hand write true expecting 'enabled', not realizing the field expects a quoted \"true\" string or a positive integer; migration scripts copying boolean flags into priority fields.","solutions":["Replace the unquoted boolean true with the quoted string \"true\" (meaning default priority/enabled).","Or set an explicit positive integer, e.g. \"priority\": 5.","Use `ipfs config --json <key> \"true\"` so the shell/JSON quoting is correct."],"exampleFix":"// before\n{\"Reprovider.Strategy\": {\"Priority\": true}}\n// after\n{\"Reprovider.Strategy\": {\"Priority\": \"true\"}}\n// or\n{\"Reprovider.Strategy\": {\"Priority\": 5}}","handlingStrategy":"validation","validationCode":"// reject bare boolean true before handing config to kubo\nfunc validPriority(v any) error {\n    if b, ok := v.(bool); ok && b {\n        return fmt.Errorf(\"Priority cannot be bare true; use \\\"true\\\" or a positive integer\")\n    }\n    return nil\n}","typeGuard":"func isQuotedTrue(v any) bool { s, ok := v.(string); return ok && s == \"true\" }","tryCatchPattern":"if err := json.Unmarshal(data, &cfg); err != nil {\n    if strings.Contains(err.Error(), \"'true' is not a valid priority\") {\n        // fix quoting in the JSON and retry\n    }\n}","preventionTips":["Use `ipfs config --json <key> <value>` instead of editing config.json raw","Remember Priority is quoted \"true\"/\"false\" or a positive int, never a JSON boolean true","Validate config.json with `ipfs config show` after manual edits"],"tags":["config","json-parsing","kubo"],"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"}