{"record":{"id":"baf6aa50560aa7e4","repo":"AdguardTeam/AdGuardHome","slug":"decoding-bool-w","errorCode":null,"errorMessage":"decoding bool: %w","messagePattern":"decoding bool: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/dhcpd/options_unix.go","lineNumber":115,"sourceCode":"\t}\n\n\tswitch bitSize {\n\tcase 8:\n\t\treturn dhcpv4.OptionGeneric{Data: []byte{uint8(v)}}, nil\n\tcase 16:\n\t\treturn dhcpv4.Uint16(v), nil\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unsupported size of integer %d\", bitSize)\n\t}\n}\n\n// parseDHCPOptionBool parses a DHCP option as a boolean value.  See\n// [strconv.ParseBool] for available values.\nfunc parseDHCPOptionBool(s string) (val dhcpv4.OptionValue, err error) {\n\tvar v bool\n\tv, err = strconv.ParseBool(s)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"decoding bool: %w\", err)\n\t}\n\n\trawVal := [1]byte{}\n\tif v {\n\t\trawVal[0] = 1\n\t}\n\n\treturn dhcpv4.OptionGeneric{Data: rawVal[:]}, nil\n}\n\n// parseDHCPOptionVal parses a DHCP option value considering typ.\nfunc parseDHCPOptionVal(typ, valStr string) (val dhcpv4.OptionValue, err error) {\n\tswitch typ {\n\tcase typBool:\n\t\tval, err = parseDHCPOptionBool(valStr)\n\tcase typDel:\n\t\tval = dhcpv4.OptionGeneric{Data: nil}\n\tcase typDur:","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/AdguardTeam/AdGuardHome/blob/b41aefbe51c8dde65e2c50f093996afa0502edf9/internal/dhcpd/options_unix.go#L97-L133","documentation":"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.","triggerScenarios":"Setting a boolean DHCP option with value 'yes', 'no', 'on', 'off', or an empty string.","commonSituations":"Operators habitually typing yes/no from other config systems; UI auto-completing 'on'; YAML configs where unquoted on/off parse as strings here.","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"],"exampleFix":"// before\n{\"code\":44,\"type\":\"bool\",\"value\":\"yes\"}\n// -> decoding bool: strconv.ParseBool: parsing \"yes\": invalid syntax\n\n// after\n{\"code\":44,\"type\":\"bool\",\"value\":\"true\"}","handlingStrategy":"validation","validationCode":"func boolOK(s string) bool {\n\t_, err := strconv.ParseBool(s)\n\treturn err == nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["dhcp","options","boolean","validation","configuration"],"backgroundTag":"invalid-boolean-value","analyzedSha":"b41aefbe51c8dde65e2c50f093996afa0502edf9","analyzedAt":"2026-08-27T04:57:55.097Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}