{"record":{"id":"4176a906c565255a","repo":"AdguardTeam/AdGuardHome","slug":"parsing-port-w","errorCode":null,"errorMessage":"parsing port: %w","messagePattern":"parsing port: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/home/options.go","lineNumber":175,"sourceCode":"\t},\n\tupdateNoValue: nil,\n\teffect:        nil,\n\tserialize: func(o options) (val string, ok bool) {\n\t\tif !o.bindHost.IsValid() {\n\t\t\treturn \"\", false\n\t\t}\n\n\t\treturn o.bindHost.String(), true\n\t},\n\tdescription: \"Deprecated. Host address to bind HTTP server on. Use --web-addr. \" +\n\t\t\"The short -h will work as --help in the future.\",\n\tlongName:  \"host\",\n\tshortName: \"h\",\n}, {\n\tupdateWithValue: func(o options, v string) (options, error) {\n\t\tp, err := strconv.ParseUint(v, 10, 16)\n\t\tif err != nil {\n\t\t\terr = fmt.Errorf(\"parsing port: %w\", err)\n\t\t} else {\n\t\t\to.bindPort = uint16(p)\n\t\t}\n\n\t\treturn o, err\n\t},\n\tupdateNoValue: nil,\n\teffect:        nil,\n\tserialize: func(o options) (val string, ok bool) {\n\t\tif o.bindPort == 0 {\n\t\t\treturn \"\", false\n\t\t}\n\n\t\treturn strconv.Itoa(int(o.bindPort)), true\n\t},\n\tdescription: \"Deprecated. Port to serve HTTP pages on. Use --web-addr.\",\n\tlongName:    \"port\",\n\tshortName:   \"p\",","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/AdguardTeam/AdGuardHome/blob/b41aefbe51c8dde65e2c50f093996afa0502edf9/internal/home/options.go#L157-L193","documentation":"The -p/--port command-line flag value could not be parsed as an unsigned 16-bit integer. strconv.ParseUint(v, 10, 16) fails on non-numeric input, negative numbers, or values above 65535.","triggerScenarios":"Passing -p abc, -p -1, -p 70000, or -p 443.5 on the command line; the value comes from the port option's updateWithValue handler during option parsing.","commonSituations":"Typos in CLI args, scripts quoting the port wrongly, or copy-pasting an address like 0.0.0.0:3000 into -p (only the number belongs there).","solutions":["Pass a plain decimal integer between 1 and 65535: -p 3000","If you meant to bind an address, use -h for host and -p for port separately","Check for stray whitespace/quotes in wrapper scripts or service unit files"],"exampleFix":"# before\n./AdGuardHome -p \"3000tcp\"\n\n# after\n./AdGuardHome -p 3000","handlingStrategy":"validation","validationCode":"if p, err := strconv.ParseUint(v, 10, 16); err != nil || p == 0 {\n    return fmt.Errorf(\"port must be 1-65535, got %q\", v)\n}","typeGuard":"func isValidPort(s string) bool { p, err := strconv.ParseUint(s, 10, 16); return err == nil && p >= 1 }","tryCatchPattern":null,"preventionTips":["Pass only plain decimal integers to -p","Set defaults in scripts to avoid empty expansions"],"tags":["go","cli","argument-parsing","port","validation"],"backgroundTag":"invalid-cli-argument","analyzedSha":"b41aefbe51c8dde65e2c50f093996afa0502edf9","analyzedAt":"2026-08-27T04:57:55.097Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}