{"record":{"id":"2255303a268092dd","repo":"JuliusBrussee/caveman","slug":"listen-address-q-must-be-loopback-host-port","errorCode":null,"errorMessage":"listen address %q must be loopback host:port","messagePattern":"listen address %q must be loopback host:port","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"proxy/internal/config/config.go","lineNumber":317,"sourceCode":"\t}\n\tfor _, r := range token {\n\t\tif r == ' ' || r < 0x20 || r == 0x7f {\n\t\t\treturn fmt.Errorf(\"CAVEMAN_AUTH_TOKEN must contain no spaces or control characters\")\n\t\t}\n\t}\n\treturn nil\n}\n\n// validateListen keeps standalone's BYOK proxy local to one operator unless an\n// inbound credential gates it. Binding an empty, wildcard, or non-loopback host\n// would expose every configured provider credential to the network with no\n// inbound authentication; authenticated says CAVEMAN_AUTH_TOKEN is set, so\n// standalone.Auth rejects every request that does not present it and the wider\n// bind becomes a deliberate operator choice instead of an accident.\nfunc validateListen(listen string, authenticated bool) error {\n\thost, port, err := net.SplitHostPort(strings.TrimSpace(listen))\n\tif err != nil || port == \"\" {\n\t\treturn fmt.Errorf(\"listen address %q must be loopback host:port\", listen)\n\t}\n\tif strings.EqualFold(host, \"localhost\") {\n\t\treturn nil\n\t}\n\tip := net.ParseIP(host)\n\tif ip == nil || !ip.IsLoopback() {\n\t\tif authenticated {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"listen address %q is not loopback; standalone proxy has no inbound authentication; set CAVEMAN_AUTH_TOKEN to expose the proxy beyond loopback\", listen)\n\t}\n\treturn nil\n}\n\nfunc (c Config) withDefaults() Config {\n\tif label := env.String(\"CAVEMAN_LABEL\", \"\"); label != \"\" {\n\t\tc.Label = label\n\t}","sourceCodeStart":299,"sourceCodeEnd":335,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/proxy/internal/config/config.go#L299-L335","documentation":"The listen address could not be split into a non-empty host and port, so it is not a valid host:port pair for a loopback listener. validateListen runs SplitHostPort and requires both parts to be present.","triggerScenarios":"Setting the listen config to a value like \":8080\" (empty host with bad split outcome), \"127.0.0.1\" (missing port), \":\" (empty port), or a value with a stray bracket/colon that SplitHostPort cannot parse; Load then returns this error.","commonSituations":"Forgetting the :port suffix; writing a bare IPv6 address without brackets; typo like \"localhost::8080\"; config value containing extra quotes copied from docs.","solutions":["Use an explicit loopback host:port, e.g. \"127.0.0.1:8080\" or \"localhost:8080\".","For IPv6 loopback, bracket the address: \"[::1]:8080\".","Strip stray whitespace/quotes from the config value (the function already trims spaces, but not quotes)."],"exampleFix":"// before\nlisten = \"127.0.0.1\"\n// after\nlisten = \"127.0.0.1:8080\"","handlingStrategy":"validation","validationCode":"host, port, err := net.SplitHostPort(strings.TrimSpace(listen))\nif err != nil || port == \"\" {\n    return fmt.Errorf(\"listen must be host:port, got %q\", listen)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always specify listen as host:port (e.g. 127.0.0.1:8080).","Bracket IPv6 addresses: [::1]:8080.","Lint config files for required :port suffix on listen values."],"tags":["config","network","listen-address"],"backgroundTag":"invalid-config-value","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}