AdguardTeam/AdGuardHome · error

unknown option type %q

Error message

unknown option type %q

What it means

Returned by parseDHCPOptionVal when an option's declared type is not one of the known types (ip, ips, hex, dur, u8, u16, bool, string). The message prints the offending type with %q so unexpected whitespace or case is visible ('Bool ' vs 'bool').

Source

Thrown at internal/dhcpd/options_unix.go:148

		val, err = parseDHCPOptionBool(valStr)
	case typDel:
		val = dhcpv4.OptionGeneric{Data: nil}
	case typDur:
		val, err = parseDHCPOptionDur(valStr)
	case typHex:
		val, err = parseDHCPOptionHex(valStr)
	case typIP:
		val, err = parseDHCPOptionIP(valStr)
	case typIPs:
		val, err = parseDHCPOptionIPs(valStr)
	case typText:
		val = dhcpv4.String(valStr)
	case typU8:
		val, err = parseDHCPOptionUint(valStr, 8)
	case typU16:
		val, err = parseDHCPOptionUint(valStr, 16)
	default:
		err = fmt.Errorf("unknown option type %q", typ)
	}

	return val, err
}

// parseDHCPOption parses an option.  For the del option value is ignored.  The
// examples of possible option strings:
//
//   - 1  bool true
//   - 2  del
//   - 3  dur  2h5s
//   - 4  hex  736f636b733a2f2f70726f78792e6578616d706c652e6f7267
//   - 5  ip   192.168.1.1
//   - 6  ips  192.168.1.1,192.168.1.2
//   - 7  text http://192.168.1.1/wpad.dat
//   - 8  u8   255
//   - 9  u16  65535
func parseDHCPOption(s string) (code dhcpv4.OptionCode, val dhcpv4.OptionValue, err error) {

View on GitHub (pinned to b41aefbe51)

Solutions

  1. Use exactly the documented lowercase type names: ip, ips, hex, dur, u8, u16, bool, string
  2. In 'code:type:value' string form, ensure no spaces around the colons (parts are not trimmed)
  3. Check the current list of supported types in the codebase's typ* constants or docs for your version

Example fix

// before
"type":"uint8"
// -> unknown option type "uint8"

// after
"type":"u8"
Defensive patterns

Strategy: type-guard

Validate before calling

var validOptTypes = map[string]bool{"ip":true,"ips":true,"hex":true,"dur":true,"u8":true,"u16":true,"bool":true,"string":true}
if !validOptTypes[typ] { /* reject before submitting */ }

Type guard

func isValidOptionType(t string) bool {
	switch t {
	case "ip", "ips", "hex", "dur", "u8", "u16", "bool", "string":
		return true
	}
	return false
}

Prevention

When it happens

Trigger: Typing the type incorrectly: 'IP' instead of 'ip', 'uint8' instead of 'u8', 'int' — plus trailing spaces or tabs inside the type token when parsing 'code:type:value' strings.

Common situations: Writing options in the CLI/YAML shorthand where a stray space splits the token; guessing type names instead of checking docs; version drift after new types were introduced/renamed.

Related errors


AI-assisted analysis of AdguardTeam/AdGuardHome@b41aefbe51 (2026-08-27). Data as JSON: /api/errors/64988733ab1601f5. Report an issue: GitHub.