gofiber/fiber · error

the URL is incorrect

Error message

the URL is incorrect

What it means

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.

Source

Thrown at client/core.go:301

}

// releaseErrChan returns the error channel to the pool.
// It's caller's responsibility to ensure that:
// - the channel is not closed
// - the channel is drained before returning it
// - the channel is not reused after returning it
func releaseErrChan(ch chan error) {
	errChanPool.Put(ch)
}

// newCore returns a new core object.
func newCore() *core {
	return &core{}
}

var (
	ErrTimeoutOrCancel      = errors.New("timeout or cancel")
	ErrURLFormat            = errors.New("the URL is incorrect")
	ErrNotSupportSchema     = errors.New("protocol not supported; only http or https are allowed")
	ErrFileNoName           = errors.New("the file should have a name")
	ErrBodyType             = errors.New("the body type should be []byte")
	ErrNotSupportSaveMethod = errors.New("only file paths and io.Writer are supported")
	ErrBodyTypeNotSupported = errors.New("the body type is not supported")
)

View on GitHub (pinned to a105acad6c)

Solutions

  1. Set a fully-qualified baseURL on the client: client.SetBaseURL("https://api.example.com").
  2. Or pass a full URL to Request.SetURL("https://api.example.com/users").
  3. Validate user-supplied URLs with net/url.Parse and require Scheme in {http, https} before calling SetURL.
  4. Ensure baseURL itself starts with http:// or https:// — relative base URLs are not supported.

Example fix

// before
client := fiber.New().SetURL
req := client.Get().SetURL("/users") // no baseURL -> ErrURLFormat

// after
client := fiber.NewClient(fiber.Config{})
client.SetBaseURL("https://api.example.com")
req := client.Get().SetURL("/users")
Defensive patterns

Strategy: validation

Validate before calling

func validateURL(baseURL, requestURL string) error {
    full := requestURL
    if !strings.HasPrefix(strings.ToLower(full), "http://") && !strings.HasPrefix(strings.ToLower(full), "https://") {
        full = baseURL + requestURL
    }
    u, err := url.Parse(full)
    if err != nil || (u.Scheme != "http" && u.Scheme != "https") {
        return fiber.ErrURLFormat
    }
    return nil
}

Try / catch

resp, err := req.Send()
if errors.Is(err, fiber.ErrURLFormat) {
    // log the configured baseURL and the request URL, fix configuration
}

Prevention

When it happens

Trigger: 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://...".

Common situations: 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.

Related errors


AI-assisted analysis of gofiber/fiber@a105acad6c (2026-08-11). Data as JSON: /api/errors/eb3bca2342220a75. Report an issue: GitHub.