AdguardTeam/AdGuardHome · error
decoding bool: %w
Error message
decoding bool: %w
What it means
Returned by parseDHCPOptionBool when a DHCP option typed bool fails strconv.ParseBool. Accepted literals are exactly: 1, t, T, TRUE, true, True, 0, f, F, FALSE, false, False. Anything else (yes/no, on/off) is rejected.
Source
Thrown at internal/dhcpd/options_unix.go:115
}
switch bitSize {
case 8:
return dhcpv4.OptionGeneric{Data: []byte{uint8(v)}}, nil
case 16:
return dhcpv4.Uint16(v), nil
default:
return nil, fmt.Errorf("unsupported size of integer %d", bitSize)
}
}
// parseDHCPOptionBool parses a DHCP option as a boolean value. See
// [strconv.ParseBool] for available values.
func parseDHCPOptionBool(s string) (val dhcpv4.OptionValue, err error) {
var v bool
v, err = strconv.ParseBool(s)
if err != nil {
return nil, fmt.Errorf("decoding bool: %w", err)
}
rawVal := [1]byte{}
if v {
rawVal[0] = 1
}
return dhcpv4.OptionGeneric{Data: rawVal[:]}, nil
}
// parseDHCPOptionVal parses a DHCP option value considering typ.
func parseDHCPOptionVal(typ, valStr string) (val dhcpv4.OptionValue, err error) {
switch typ {
case typBool:
val, err = parseDHCPOptionBool(valStr)
case typDel:
val = dhcpv4.OptionGeneric{Data: nil}
case typDur:View on GitHub (pinned to b41aefbe51)
Solutions
- Replace yes/no and on/off with true/false
- Use the exact literals accepted by strconv.ParseBool (safest: true and false)
- Quote the value in JSON/YAML to avoid boolean-coercion surprises
Example fix
// before
{"code":44,"type":"bool","value":"yes"}
// -> decoding bool: strconv.ParseBool: parsing "yes": invalid syntax
// after
{"code":44,"type":"bool","value":"true"} Defensive patterns
Strategy: validation
Validate before calling
func boolOK(s string) bool {
_, err := strconv.ParseBool(s)
return err == nil
} Prevention
- Use true/false, never yes/no or on/off
- Quote booleans in YAML/JSON configs
- Check strconv.ParseBool's accepted literal list when in doubt
When it happens
Trigger: Setting a boolean DHCP option with value 'yes', 'no', 'on', 'off', or an empty string.
Common situations: Operators habitually typing yes/no from other config systems; UI auto-completing 'on'; YAML configs where unquoted on/off parse as strings here.
Related errors
AI-assisted analysis of AdguardTeam/AdGuardHome@b41aefbe51 (2026-08-27).
Data as JSON: /api/errors/baf6aa50560aa7e4.
Report an issue: GitHub.