Billionmail/BillionMail · warning

base URL must use http or https protocol

Error message

base URL must use http or https protocol

What it means

After parsing succeeds, Testing requires the URL scheme to be exactly http or https. Any other scheme (ftp://, file://, ws://, etc.) is rejected with this error so that Testing never attempts HTTP requests against non-HTTP endpoints.

Source

Thrown at core/internal/service/askai/supplier.go:493

// Testing validates the supplier's configuration by checking the base URL and API key.
// It performs the following checks:
// 1. Validates the base URL format.
// 2. Tests the accessibility of the base URL by sending a HEAD request.
// 3. Validates the API key by sending a GET request to the models endpoint.
// If any of these checks fail, it returns an error indicating the issue.
func Testing(supplierName, baseUrl, apiKey string) error {
	if supplierName == "" || baseUrl == "" || apiKey == "" {
		return errors.New("supplier name, base URL, and API key are required")
	}

	// Validate base URL format
	parsedUrl, err := url.ParseRequestURI(baseUrl)
	if err != nil {
		return fmt.Errorf("invalid base URL format: %w", err)
	}
	if parsedUrl.Scheme != "http" && parsedUrl.Scheme != "https" {
		return errors.New("base URL must use http or https protocol")
	}
	// Ensure the base URL ends with a slash
	if err := testBaseURLAccessibility(baseUrl); err != nil {
		return fmt.Errorf("base URL accessibility test failed: %w", err)
	}
	// Validate API key by making a request to the models endpoint
	if err := testAPIKeyValidity(baseUrl, apiKey); err != nil {
		return fmt.Errorf("API key validation failed: %w", err)
	}

	return nil
}

// testBaseURLAccessibility checks if the base URL is accessible by sending a HEAD request.
// It returns an error if the request fails or if the response status is not OK (200).
func testBaseURLAccessibility(baseUrl string) error {
	client := &http.Client{Timeout: 3 * time.Second}
	resp, err := client.Head(baseUrl)

View on GitHub (pinned to fc36c76c05)

Solutions

  1. Prefix the endpoint with https:// (preferred) or http:// for local testing
  2. Fix typos in the scheme (hhttps, httpss)
  3. Use an HTTP(S) AI-compatible endpoint rather than other protocols

Example fix

// before
err := askai.Testing(name, "ftp://files.example.com", key)
// after
err := askai.Testing(name, "https://api.example.com/v1", key)
Defensive patterns

Strategy: validation

Validate before calling

func hasHTTPScheme(raw string) bool {
    u, err := url.ParseRequestURI(strings.TrimSpace(raw))
    return err == nil && (u.Scheme == "http" || u.Scheme == "https")
}
if !hasHTTPScheme(baseUrl) {
    return errors.New("endpoint must start with http:// or https://")
}

Try / catch

if err := askai.Testing(name, baseUrl, apiKey); err != nil {
    if err.Error() == "base URL must use http or https protocol" {
        return fmt.Errorf("unsupported protocol in %q; use http(s)", baseUrl)
    }
    return err
}

Prevention

When it happens

Trigger: Calling askai.Testing with a baseUrl whose scheme is not http/https, e.g. 'ftp://host', 'file:///path', or a URL that defaults to an unexpected scheme after parsing.

Common situations: Pasting a URL with a typo'd scheme (hhttps://, http:||); using a websocket-style endpoint; internal file URLs entered by mistake; scheme uppercase mismatch is fine (parsed scheme is lowercased) but a missing '//' can yield a different parse result.

Related errors


AI-assisted analysis of Billionmail/BillionMail@fc36c76c05 (2026-09-05). Data as JSON: /api/errors/310b06ca8268f0f8. Report an issue: GitHub.