ipfs/kubo · error
'true' is not a valid priority
Error message
'true' is not a valid priority
What it means
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.
Source
Thrown at config/types.go:200
// <= 0 == special
switch p {
case DefaultPriority:
return json.Marshal(nil)
case Disabled:
return json.Marshal(false)
default:
return nil, fmt.Errorf("invalid priority value: %d", p)
}
}
func (p *Priority) UnmarshalJSON(input []byte) error {
switch string(input) {
case "null", "undefined":
*p = DefaultPriority
case "false":
*p = Disabled
case "true":
return fmt.Errorf("'true' is not a valid priority")
default:
var priority int64
err := json.Unmarshal(input, &priority)
if err != nil {
return err
}
if priority <= 0 {
return fmt.Errorf("priority must be positive: %d <= 0", priority)
}
*p = Priority(priority)
}
return nil
}
func (p Priority) String() string {
if p > 0 {
return fmt.Sprintf("%d", p)
}View on GitHub (pinned to 329838acdf)
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.
Example fix
// before
{"Reprovider.Strategy": {"Priority": true}}
// after
{"Reprovider.Strategy": {"Priority": "true"}}
// or
{"Reprovider.Strategy": {"Priority": 5}} Defensive patterns
Strategy: validation
Validate before calling
// reject bare boolean true before handing config to kubo
func validPriority(v any) error {
if b, ok := v.(bool); ok && b {
return fmt.Errorf("Priority cannot be bare true; use \"true\" or a positive integer")
}
return nil
} Type guard
func isQuotedTrue(v any) bool { s, ok := v.(string); return ok && s == "true" } Try / catch
if err := json.Unmarshal(data, &cfg); err != nil {
if strings.Contains(err.Error(), "'true' is not a valid priority") {
// fix quoting in the JSON and retry
}
} Prevention
- 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
When it happens
Trigger: Unmarshaling JSON config such as {"priority": true} (unquoted boolean true) into a Priority field via json.Unmarshal or `ipfs config --json`.
Common situations: 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.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- private networking (swarm.key / LIBP2P_FORCE_PNET) does not
- Routing.AcceleratedDHTClient option is set even tho Routing.
- serveHTTPApi: GetConfig() failed: %s
- serveHTTPApi: invalid API address: %q (err: %s)
- priority must be positive: %d <= 0
AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03).
Data as JSON: /api/errors/94dd9dbf12590c05.
Report an issue: GitHub.