{"record":{"id":"7ed18e74fdbc7d4a","repo":"Billionmail/BillionMail","slug":"supplier-configuration-not-found","errorCode":null,"errorMessage":"supplier configuration not found","messagePattern":"supplier configuration not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/internal/service/askai/supplier.go","lineNumber":467,"sourceCode":"\tif err != nil {\n\t\treturn nil, err\n\t}\n\tvar supplierConfig Supplier\n\terr = json.Unmarshal(fBody, &supplierConfig)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn &supplierConfig, nil\n}\n\n// SetSupplierConfig updates the supplier configuration with the provided base URL and API key.\n// It reads the existing configuration, modifies it, and saves it back to the file.\n// If the configuration file does not exist, it returns an error indicating that the supplier configuration was not found.\n// This function is useful for updating the supplier's API settings without needing to recreate the entire configuration.\nfunc SetSupplierConfig(supplierName string, baseUrl string, apiKey string) error {\n\tsupplierConfig, err := ReadSupplierConfig(supplierName)\n\tif err != nil {\n\t\treturn errors.New(\"supplier configuration not found\")\n\t}\n\n\tsupplierConfig.BaseUrl = baseUrl\n\tsupplierConfig.ApiKey = apiKey\n\n\treturn SaveSupplierConfig(supplierName, *supplierConfig)\n}\n\n// Testing validates the supplier's configuration by checking the base URL and API key.\n// It performs the following checks:\n// 1. Validates the base URL format.\n// 2. Tests the accessibility of the base URL by sending a HEAD request.\n// 3. Validates the API key by sending a GET request to the models endpoint.\n// If any of these checks fail, it returns an error indicating the issue.\nfunc Testing(supplierName, baseUrl, apiKey string) error {\n\tif supplierName == \"\" || baseUrl == \"\" || apiKey == \"\" {\n\t\treturn errors.New(\"supplier name, base URL, and API key are required\")\n\t}","sourceCodeStart":449,"sourceCodeEnd":485,"githubUrl":"https://github.com/Billionmail/BillionMail/blob/fc36c76c050c3775c5e899faf7403cf0262d2744/core/internal/service/askai/supplier.go#L449-L485","documentation":"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.","triggerScenarios":"Calling SetSupplierConfig(name, baseUrl, apiKey) for a supplier whose config file was never created (via a save/creation path) or whose name is misspelled.","commonSituations":"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.","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"],"exampleFix":"// before\nerr := askai.SetSupplierConfig(\"openai\", url, key) // fails if not yet created\n// after\nif err := askai.SetSupplierConfig(\"openai\", url, key); err != nil && err.Error() == \"supplier configuration not found\" {\n    err = askai.SaveSupplierConfig(\"openai\", askai.Supplier{Name: \"openai\", BaseUrl: url, ApiKey: key})\n}","handlingStrategy":"try-catch","validationCode":"func supplierExists(name string) bool {\n    _, err := askai.ReadSupplierConfig(name)\n    return err == nil\n}\nif !supplierExists(supplierName) {\n    // create it first via the save/creation API\n}","typeGuard":null,"tryCatchPattern":"if err := askai.SetSupplierConfig(name, baseUrl, apiKey); err != nil {\n    if err.Error() == \"supplier configuration not found\" {\n        err = askai.SaveSupplierConfig(name, askai.Supplier{Name: name, BaseUrl: baseUrl, ApiKey: apiKey})\n    }\n    if err != nil { return err }\n}","preventionTips":["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"],"tags":["go","configuration","supplier","not-found"],"backgroundTag":"config-not-found","analyzedSha":"fc36c76c050c3775c5e899faf7403cf0262d2744","analyzedAt":"2026-09-05T21:28:54.019Z","contentChangedAt":"2026-09-05T21:28:54.019Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}