{"record":{"id":"0ab206eb65ee2758","repo":"AdguardTeam/AdGuardHome","slug":"could-not-find-hardware-port-for-s","errorCode":null,"errorMessage":"could not find hardware port for %s","messagePattern":"could not find hardware port for (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"internal/aghnet/net_darwin.go","lineNumber":59,"sourceCode":"\tif err != nil {\n\t\treturn false, err\n\t}\n\n\treturn portInfo.static, nil\n}\n\n// getCurrentHardwarePortInfo returns information for the specified network\n// interface.  cmdCons must not be nil.\nfunc getCurrentHardwarePortInfo(\n\tctx context.Context,\n\tcmdCons executil.CommandConstructor,\n\tifaceName string,\n) (hardwarePortInfo, error) {\n\t// First, find the hardware port name.\n\tm := getNetworkSetupHardwareReports(ctx, cmdCons)\n\thardwarePort, ok := m[ifaceName]\n\tif !ok {\n\t\treturn hardwarePortInfo{}, fmt.Errorf(\"could not find hardware port for %s\", ifaceName)\n\t}\n\n\treturn getHardwarePortInfo(ctx, cmdCons, hardwarePort)\n}\n\n// hardwareReportsReg is the regular expression matching the lines of\n// networksetup command output lines containing the interface information.\nvar hardwareReportsReg = regexp.MustCompile(\"Hardware Port: (.*?)\\nDevice: (.*?)\\n\")\n\n// getNetworkSetupHardwareReports returns a map of interface names to hardware\n// port names.  It returns nil if parsing fails.  cmdCons must not be nil.\n//\n// TODO(e.burkov):  There should be more proper approach than parsing the\n// command output.  For example, see\n// https://developer.apple.com/documentation/systemconfiguration.\nfunc getNetworkSetupHardwareReports(\n\tctx context.Context,\n\tcmdCons executil.CommandConstructor,","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/AdguardTeam/AdGuardHome/blob/b41aefbe51c8dde65e2c50f093996afa0502edf9/internal/aghnet/net_darwin.go#L41-L77","documentation":"parseReason iterates over every value of a reason search criterion and rejects any name not present in filtering.ReasonByName. Each bad value produces an error wrapping errors.ErrBadEnumValue with the offending string; the errors are aggregated and returned.","triggerScenarios":"GET /control/querylog with search=reason(...) where any value inside the parentheses is not a registered filtering reason name (e.g. a typo or a reason only produced by a different version).","commonSituations":"Listing reason names from filtering logs of a newer version against an older server; typos; mixing up filtering status names with reason names.","solutions":["Use only reason names registered in filtering.ReasonByName (check the filtering package or API docs)","Fix typos in the reason value and retry","Upgrade server/client to matching versions if the reason was added recently"],"exampleFix":"// before\nGET /control/querylog?search=reason(FilteredUnknown)\n// after\nGET /control/querylog?search=reason(FilteredBlackList) // a registered reason name","handlingStrategy":"validation","validationCode":"if _, ok := filtering.ReasonByName[val]; !ok { return fmt.Errorf(\"unknown reason %q\", val) }","typeGuard":"func isKnownReason(name string) bool {\n    _, ok := filtering.ReasonByName[name]\n    return ok\n}","tryCatchPattern":"if resp.StatusCode == 400 && strings.Contains(body, errors.ErrBadEnumValue.Error()) {\n    // filter out unknown reasons and retry\n}","preventionTips":["Use reason names exported by the filtering package","Avoid hardcoding reason strings; derive from the API","Upgrade client and server together"],"tags":["querylog","search","filtering","validation","go"],"backgroundTag":"enum-validation-failed","analyzedSha":"b41aefbe51c8dde65e2c50f093996afa0502edf9","analyzedAt":"2026-08-27T04:57:55.097Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}