{"record":{"id":"7358814e5d60cd58","repo":"cloudflare/cloudflared","slug":"errbadrequest","errorCode":"ErrBadRequest","errorMessage":"incorrect request parameters","messagePattern":"incorrect request parameters","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cfapi/base_client.go","lineNumber":25,"sourceCode":"\t\"io\"\n\t\"net/http\"\n\t\"net/url\"\n\t\"strings\"\n\t\"time\"\n\n\t\"github.com/pkg/errors\"\n\t\"github.com/rs/zerolog\"\n\t\"golang.org/x/net/http2\"\n)\n\nconst (\n\tdefaultTimeout  = 15 * time.Second\n\tjsonContentType = \"application/json\"\n)\n\nvar (\n\tErrUnauthorized = errors.New(\"unauthorized\")\n\tErrBadRequest   = errors.New(\"incorrect request parameters\")\n\tErrNotFound     = errors.New(\"not found\")\n\tErrAPINoSuccess = errors.New(\"API call failed\")\n)\n\ntype RESTClient struct {\n\tbaseEndpoints *baseEndpoints\n\tauthToken     string\n\tuserAgent     string\n\tclient        http.Client\n\tlog           *zerolog.Logger\n}\n\ntype baseEndpoints struct {\n\taccountLevel  url.URL\n\tzoneLevel     url.URL\n\taccountRoutes url.URL\n\taccountVnets  url.URL\n}","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/cloudflare/cloudflared/blob/2253eeeb25a44a713a4b60b8ba1e1b3f377d1a0f/cfapi/base_client.go#L7-L43","documentation":"ErrBadRequest is a sentinel error returned by statusCodeToError when the Cloudflare API responds with HTTP 400 (Bad Request), meaning the request parameters were malformed or invalid. The REST client maps that status to this error instead of the raw response body.","triggerScenarios":"Any cfapi REST call with invalid or missing query/body parameters: malformed tunnel IDs, invalid hostname configurations, bad JSON payloads, unknown route parameters, or values outside API-accepted ranges (HTTP 400 from api.cloudflare.com).","commonSituations":"Outdated cloudflared sending deprecated request fields the API now rejects, mistyped tunnel IDs in flags/config, invalid remote-managed configuration JSON, or version drift between the client's request schema and the API.","solutions":["Log/inspect the full API response body to get the specific Cloudflare error code (e.g. 1003, 7003).","Validate the identifiers being sent (tunnel ID format, account ID) before the call.","Upgrade cloudflared to the latest version so request payloads match the current API schema.","Fix the originating flags/config values that produced the malformed request."],"exampleFix":"// before\ntunnelID := cfg.TunnelID // \"abc\" (truncated)\n// after\ntunnelID := cfg.TunnelID // full 36-char UUID, validated with uuid.Parse before calling the API","handlingStrategy":"type-guard","validationCode":"_, err := uuid.Parse(tunnelID)\nif err != nil {\n    return fmt.Errorf(\"invalid tunnel ID %q: %w\", tunnelID, err)\n}","typeGuard":"import \"errors\"\n\nfunc IsBadRequest(err error) bool {\n    return errors.Is(err, ErrBadRequest)\n}","tryCatchPattern":"resp, err := client.GetTunnelConfiguration(ctx, accountID, connID)\nif err != nil {\n    if errors.Is(err, ErrBadRequest) {\n        return fmt.Errorf(\"invalid request parameters, check IDs and payload: %w\", err)\n    }\n    return err\n}","preventionTips":["Validate all IDs (UUID format) before issuing API calls","Keep cloudflared up to date so request schemas match the API","Log response bodies on 400s to capture the specific Cloudflare error code"],"tags":["go","cloudflare","api","bad-request"],"backgroundTag":"http-error-response","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"}