{"record":{"id":"eb3bca2342220a75","repo":"gofiber/fiber","slug":"the-url-is-incorrect","errorCode":null,"errorMessage":"the URL is incorrect","messagePattern":"the URL is incorrect","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"client/core.go","lineNumber":301,"sourceCode":"}\n\n// releaseErrChan returns the error channel to the pool.\n// It's caller's responsibility to ensure that:\n// - the channel is not closed\n// - the channel is drained before returning it\n// - the channel is not reused after returning it\nfunc releaseErrChan(ch chan error) {\n\terrChanPool.Put(ch)\n}\n\n// newCore returns a new core object.\nfunc newCore() *core {\n\treturn &core{}\n}\n\nvar (\n\tErrTimeoutOrCancel      = errors.New(\"timeout or cancel\")\n\tErrURLFormat            = errors.New(\"the URL is incorrect\")\n\tErrNotSupportSchema     = errors.New(\"protocol not supported; only http or https are allowed\")\n\tErrFileNoName           = errors.New(\"the file should have a name\")\n\tErrBodyType             = errors.New(\"the body type should be []byte\")\n\tErrNotSupportSaveMethod = errors.New(\"only file paths and io.Writer are supported\")\n\tErrBodyTypeNotSupported = errors.New(\"the body type is not supported\")\n)\n","sourceCodeStart":283,"sourceCodeEnd":308,"githubUrl":"https://github.com/gofiber/fiber/blob/a105acad6c1e4576a77f01e02973f67e962bb58d/client/core.go#L283-L308","documentation":"Returned by parserRequestURL (client/hooks.go:80) when the request URL does not begin with http:// or https:// even after the client's baseURL is prepended. The check is a regex (protocolCheck) applied first to the raw URL and again to baseURL+URL, so neither the request nor the configured base provides a valid scheme.","triggerScenarios":"Calling req.SetURL(\"/api/v1/users\") on a Request whose Client has no baseURL set; setting baseURL to \"example.com\" (missing scheme); mixing a relative URL with an empty/relative baseURL; passing a URL like \"ftp://...\".","commonSituations":"Forgetting fiber.New().SetBaseURL or assuming a default; setting baseURL without a scheme; building URLs from user input that omits the protocol; copy/pasting a URL fragment as the request URL.","solutions":["Set a fully-qualified baseURL on the client: client.SetBaseURL(\"https://api.example.com\").","Or pass a full URL to Request.SetURL(\"https://api.example.com/users\").","Validate user-supplied URLs with net/url.Parse and require Scheme in {http, https} before calling SetURL.","Ensure baseURL itself starts with http:// or https:// — relative base URLs are not supported."],"exampleFix":"// before\nclient := fiber.New().SetURL\nreq := client.Get().SetURL(\"/users\") // no baseURL -> ErrURLFormat\n\n// after\nclient := fiber.NewClient(fiber.Config{})\nclient.SetBaseURL(\"https://api.example.com\")\nreq := client.Get().SetURL(\"/users\")","handlingStrategy":"validation","validationCode":"func validateURL(baseURL, requestURL string) error {\n    full := requestURL\n    if !strings.HasPrefix(strings.ToLower(full), \"http://\") && !strings.HasPrefix(strings.ToLower(full), \"https://\") {\n        full = baseURL + requestURL\n    }\n    u, err := url.Parse(full)\n    if err != nil || (u.Scheme != \"http\" && u.Scheme != \"https\") {\n        return fiber.ErrURLFormat\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"resp, err := req.Send()\nif errors.Is(err, fiber.ErrURLFormat) {\n    // log the configured baseURL and the request URL, fix configuration\n}","preventionTips":["Always call client.SetBaseURL with a fully-qualified https:// URL at construction.","Centralize URL construction in one helper that validates the scheme.","Reject user-supplied URLs missing a scheme before passing to SetURL."],"tags":["client","url","configuration","http"],"backgroundTag":null,"analyzedSha":"a105acad6c1e4576a77f01e02973f67e962bb58d","analyzedAt":"2026-08-11T17:33:26.942Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}