{"record":{"id":"618b6d17648231e0","repo":"AdguardTeam/AdGuardHome","slug":"auth-parsing-remote-address-w","errorCode":null,"errorMessage":"auth: parsing remote address: %w","messagePattern":"auth: parsing remote address: %w","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"internal/home/authhttp.go","lineNumber":167,"sourceCode":"\t\t\treturn\n\t\t}\n\t}\n\n\tip, err := realIP(r)\n\tif err != nil {\n\t\tweb.logger.ErrorContext(\n\t\t\tctx,\n\t\t\t\"getting real ip\",\n\t\t\t\"remote_ip\", remoteIPStr,\n\t\t\tslogutil.KeyError, err,\n\t\t)\n\t}\n\n\tremoteIP, err := netip.ParseAddr(remoteIPStr)\n\tif err != nil {\n\t\tweb.writeErrorWithIP(\n\t\t\tctx,\n\t\t\tfmt.Errorf(\"auth: parsing remote address: %w\", err),\n\t\t\tr,\n\t\t\tw,\n\t\t\thttp.StatusInternalServerError,\n\t\t\tr.RemoteAddr,\n\t\t)\n\n\t\treturn\n\t}\n\n\tlogIP := remoteIPStr\n\tif web.auth.trustedProxies.Contains(remoteIP.Unmap()) {\n\t\tlogIP = ip.String()\n\t}\n\n\tcookie, err := newCookie(ctx, web.auth, req, remoteIPStr)\n\tif err != nil {\n\t\tweb.writeErrorWithIP(ctx, err, r, w, http.StatusForbidden, logIP)\n","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/AdguardTeam/AdGuardHome/blob/b41aefbe51c8dde65e2c50f093996afa0502edf9/internal/home/authhttp.go#L149-L185","documentation":"handleLogin failed to parse the client's remote address string with netip.ParseAddr, yielding an internal server error. The RemoteAddr-derived string is not a valid IP literal.","triggerScenarios":"A request whose RemoteAddr host part is empty, malformed, or a hostname rather than an IP; typically a misbehaving or custom HTTP server/proxy in front of AdGuard Home.","commonSituations":"Malformed X-Forwarded-For handling, unusual proxies, unit tests with fake RemoteAddr values like \"test\".","solutions":["Inspect r.RemoteAddr for the failing request and fix the upstream proxy/server producing it","Ensure the Go http.Server is populating RemoteAddr as host:port normally does","If behind a proxy, configure trusted proxies so the correct client IP is extracted"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// server-side: treat as 500 but log RemoteAddr for diagnosis\nif errors.Is(err, netip parse...) { log.ErrorContext(ctx, \"bad RemoteAddr\", \"addr\", r.RemoteAddr) }","preventionTips":["Ensure the fronting proxy passes well-formed addresses","In tests, set RemoteAddr to literal host:port values like \"127.0.0.1:1234\""],"tags":["auth","network","ip-parsing","http"],"backgroundTag":"invalid-ip-address","analyzedSha":"b41aefbe51c8dde65e2c50f093996afa0502edf9","analyzedAt":"2026-08-27T04:57:55.097Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}