{"record":{"id":"a20d96483a068ada","repo":"cloudflare/cloudflared","slug":"invalid-http-status-code","errorCode":null,"errorMessage":"invalid HTTP status code","messagePattern":"invalid HTTP status code","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ingress/ingress.go","lineNumber":261,"sourceCode":"}\n\nfunc validateIngress(ingress []config.UnvalidatedIngressRule, defaults OriginRequestConfig) (Ingress, error) {\n\trules := make([]Rule, len(ingress))\n\tfor i, r := range ingress {\n\t\tcfg := setConfig(defaults, r.OriginRequest)\n\t\tvar service OriginService\n\n\t\tif prefix := \"unix:\"; strings.HasPrefix(r.Service, prefix) {\n\t\t\t// No validation necessary for unix socket filepath services\n\t\t\tpath := strings.TrimPrefix(r.Service, prefix)\n\t\t\tservice = &unixSocketPath{path: path, scheme: \"http\"}\n\t\t} else if prefix := \"unix+tls:\"; strings.HasPrefix(r.Service, prefix) {\n\t\t\tpath := strings.TrimPrefix(r.Service, prefix)\n\t\t\tservice = &unixSocketPath{path: path, scheme: \"https\"}\n\t\t} else if prefix := \"http_status:\"; strings.HasPrefix(r.Service, prefix) {\n\t\t\tstatusCode, err := strconv.Atoi(strings.TrimPrefix(r.Service, prefix))\n\t\t\tif err != nil {\n\t\t\t\treturn Ingress{}, errors.Wrap(err, \"invalid HTTP status code\")\n\t\t\t}\n\t\t\tif statusCode < 100 || statusCode > 999 {\n\t\t\t\treturn Ingress{}, fmt.Errorf(\"invalid HTTP status code: %d\", statusCode)\n\t\t\t}\n\t\t\tsrv := newStatusCode(statusCode)\n\t\t\tservice = &srv\n\t\t} else if r.Service == HelloWorldFlag || r.Service == HelloWorldService {\n\t\t\tservice = new(helloWorld)\n\t\t} else if r.Service == ServiceSocksProxy {\n\t\t\trules := make([]ipaccess.Rule, len(r.OriginRequest.IPRules))\n\n\t\t\tfor i, ipRule := range r.OriginRequest.IPRules {\n\t\t\t\trule, err := ipaccess.NewRuleByCIDR(ipRule.Prefix, ipRule.Ports, ipRule.Allow)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn Ingress{}, fmt.Errorf(\"unable to create ip rule for %s: %s\", r.Service, err)\n\t\t\t\t}\n\t\t\t\trules[i] = rule\n\t\t\t}","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/ingress/ingress.go#L243-L279","documentation":"Ingress rules can use a 'http_status:CODE' service to return a fixed HTTP status. This error is wrapped when the text after 'http_status:' cannot be parsed as an integer by strconv.Atoi. The ingress config is rejected entirely and ParseIngress returns an Ingress{} zero value with this error.","triggerScenarios":"An ingress rule with service like 'http_status: twohundred', 'http_status: 200 OK', 'http_status:' (empty), or any non-numeric suffix so strconv.Atoi fails.","commonSituations":"Hand-edited config.yml with a typo or stray text in the status code, YAML quoting mistakes, or copy-pasting 'http_status:404 ' with trailing characters.","solutions":["Make the service value exactly 'http_status:<integer>', e.g. http_status:404 with no extra text.","Quote the YAML value if it may be misinterpreted: service: \"http_status:404\".","Note a separate check requires 100 <= code <= 999; pick a code in that range to avoid the sibling error."],"exampleFix":"// before\nservice: http_status: Not Found\n// after\nservice: http_status:404","handlingStrategy":"validation","validationCode":"func validHTTPStatusService(svc string) error {\n    const prefix = \"http_status:\"\n    if !strings.HasPrefix(svc, prefix) {\n        return nil\n    }\n    code, err := strconv.Atoi(strings.TrimPrefix(svc, prefix))\n    if err != nil {\n        return fmt.Errorf(\"http_status must be an integer, got %q\", svc)\n    }\n    if code < 100 || code > 999 {\n        return fmt.Errorf(\"http_status code %d out of range 100-999\", code)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"ing, err := ingress.ParseIngress(conf)\nif err != nil {\n    return fmt.Errorf(\"invalid ingress config: %w\", err)\n}","preventionTips":["Always use the exact form http_status:<digits>, no spaces or extra text.","Run `cloudflared tunnel ingress validate` after editing config.yml.","Quote YAML values containing colons."],"tags":["ingress","config-validation","http-status"],"backgroundTag":"invalid-argument-format","analyzedSha":"2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f","analyzedAt":"2026-09-06T04:14:33.757Z","contentChangedAt":"2026-09-06T04:14:33.757Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}