Billionmail/BillionMail · error
base URL accessibility test failed: %w
Error message
base URL accessibility test failed: %w
What it means
Testing probes base URL reachability with a HEAD request via testBaseURLAccessibility. Any failure — DNS failure, connection refused, timeout, TLS error, or non-success status — is wrapped as 'base URL accessibility test failed: %w'. The wrapped cause contains the real network error.
Source
Thrown at core/internal/service/askai/supplier.go:497
// 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)
if err != nil {
return err
}
defer resp.Body.Close()View on GitHub (pinned to fc36c76c05)
Solutions
- Inspect the wrapped inner error to identify the exact network cause (DNS, refused, timeout, TLS)
- Confirm the URL is reachable: curl -I <baseUrl> from the same host/network
- Check DNS, firewall, and proxy settings; for containers verify network reachability
- Verify the server accepts HEAD requests or correct the endpoint URL
- Fix TLS certificate issues or use http:// for local-only endpoints
Example fix
// before
err := askai.Testing(name, "http://localhost:9999/v1", key) // server not running
// after
// start the service first, or use the correct port
if err := exec.Command("curl", "-sfI", baseURL); err != nil { /* fix reachability */ }
err := askai.Testing(name, "http://localhost:8080/v1", key) Defensive patterns
Strategy: retry
Validate before calling
func baseURLReachable(raw string) error {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
req, err := http.NewRequestWithContext(ctx, http.MethodHead, raw, nil)
if err != nil { return err }
resp, err := http.DefaultClient.Do(req)
if err != nil { return err }
resp.Body.Close()
return nil
}
// call before askai.Testing to fail fast with a clearer error Try / catch
var err error
for attempt := 0; attempt < 3; attempt++ {
err = askai.Testing(name, baseUrl, apiKey)
if err == nil || !strings.Contains(err.Error(), "accessibility test failed") { break }
time.Sleep(time.Duration(1<<attempt) * time.Second)
}
if err != nil { return fmt.Errorf("supplier endpoint unreachable: %w", err) } Prevention
- Verify the endpoint with curl -I from the same host/network before testing
- Check DNS, firewall, and proxy configuration in the deployment environment
- Confirm the service is running and the port is correct (esp. in Docker networks)
- Keep reasonable timeouts and retry transient network failures
When it happens
Trigger: Calling askai.Testing against a host that is down, unreachable, behind a firewall, has expired TLS certificates, or returns an error HTTP status to HEAD requests.
Common situations: Typo'd hostname or wrong port; server running locally but Testing called in an environment without access (Docker network mismatch); corporate proxy blocking the request; self-signed/expired certs; endpoint only supports GET, not HEAD.
Related errors
- API key validation failed: %w
- unexpected API response: %d %s
- download file failed:
- base URL not configured
- request context is nil
AI-assisted analysis of Billionmail/BillionMail@fc36c76c05 (2026-09-05).
Data as JSON: /api/errors/02aa881a58c59b62.
Report an issue: GitHub.