Billionmail/BillionMail · error
supplier configuration not found
Error message
supplier configuration not found
What it means
SetSupplierConfig updates an existing supplier's BaseUrl and ApiKey by reading the current config first. If ReadSupplierConfig fails — typically because no configuration file exists for that supplier name — the read error is discarded and replaced with the generic message 'supplier configuration not found'. Only existing suppliers can be updated; this API does not create them.
Source
Thrown at core/internal/service/askai/supplier.go:467
if err != nil {
return nil, err
}
var supplierConfig Supplier
err = json.Unmarshal(fBody, &supplierConfig)
if err != nil {
return nil, err
}
return &supplierConfig, nil
}
// SetSupplierConfig updates the supplier configuration with the provided base URL and API key.
// It reads the existing configuration, modifies it, and saves it back to the file.
// If the configuration file does not exist, it returns an error indicating that the supplier configuration was not found.
// This function is useful for updating the supplier's API settings without needing to recreate the entire configuration.
func SetSupplierConfig(supplierName string, baseUrl string, apiKey string) error {
supplierConfig, err := ReadSupplierConfig(supplierName)
if err != nil {
return errors.New("supplier configuration not found")
}
supplierConfig.BaseUrl = baseUrl
supplierConfig.ApiKey = apiKey
return SaveSupplierConfig(supplierName, *supplierConfig)
}
// 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")
}View on GitHub (pinned to fc36c76c05)
Solutions
- Verify the supplier name matches an existing configuration exactly (case/spelling)
- Create the supplier configuration first with a save/creation API before attempting updates
- Check the supplier config file exists on disk for that name
- If you need create-or-update semantics, handle the not-found case by creating a new config instead
Example fix
// before
err := askai.SetSupplierConfig("openai", url, key) // fails if not yet created
// after
if err := askai.SetSupplierConfig("openai", url, key); err != nil && err.Error() == "supplier configuration not found" {
err = askai.SaveSupplierConfig("openai", askai.Supplier{Name: "openai", BaseUrl: url, ApiKey: key})
} Defensive patterns
Strategy: try-catch
Validate before calling
func supplierExists(name string) bool {
_, err := askai.ReadSupplierConfig(name)
return err == nil
}
if !supplierExists(supplierName) {
// create it first via the save/creation API
} Try / catch
if err := askai.SetSupplierConfig(name, baseUrl, apiKey); err != nil {
if err.Error() == "supplier configuration not found" {
err = askai.SaveSupplierConfig(name, askai.Supplier{Name: name, BaseUrl: baseUrl, ApiKey: apiKey})
}
if err != nil { return err }
} Prevention
- Always create a supplier's config before attempting updates
- Use a single source of truth (e.g., a constants list) for supplier names to avoid typos
- Do not discard the inner error when wrapping — it aids diagnosis
- Persist supplier configs on durable storage
When it happens
Trigger: Calling SetSupplierConfig(name, baseUrl, apiKey) for a supplier whose config file was never created (via a save/creation path) or whose name is misspelled.
Common situations: Typo in the supplier name passed to SetSupplierConfig; calling update before any initial supplier creation; config file deleted from disk; calling on a fresh install where no suppliers are registered yet.
Related errors
- Failed to get configuration
- Supplier not found
- error reading knowledge base: %v
- supplier name, base URL, and API key are required
- invalid base URL format: %w
AI-assisted analysis of Billionmail/BillionMail@fc36c76c05 (2026-09-05).
Data as JSON: /api/errors/7ed18e74fdbc7d4a.
Report an issue: GitHub.