{"record":{"id":"93989aea19c3162d","repo":"Billionmail/BillionMail","slug":"model-not-found-93989a","errorCode":null,"errorMessage":"model not found","messagePattern":"model not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/internal/service/askai/supplier.go","lineNumber":591,"sourceCode":"\n// SetModelStatus updates the status of a specific model in the supplier's models.json file.\n// It reads the existing models, modifies the status of the specified model, and saves the updated list back to the file.\n// If the model is not found, it returns an error indicating that the model does not exist\nfunc SetModelStatus(supplierName string, modelId string, status bool) error {\n\tmodelsFile := SUPPLIER_CONFIG_PATH + \"/\" + supplierName + \"/models.json\"\n\n\t// Read existing models\n\texistingModels := GetModelList(supplierName)\n\n\t// Update the model status\n\tfor i, model := range existingModels {\n\t\tif model.ModelId == modelId {\n\t\t\texistingModels[i].Status = status\n\t\t\treturn saveModelsToFile(modelsFile, existingModels)\n\t\t}\n\t}\n\n\treturn errors.New(\"model not found\")\n}\n\n// AddSupplier creates a new supplier configuration file with the provided details.\n// It checks if a supplier with the same name already exists, and if not, it creates a new Supplier struct\nfunc AddSupplier(supplierTitle string, supplierName string, baseUrl string, apiKey string) error {\n\tsupplierPath := SUPPLIER_CONFIG_PATH + \"/\" + supplierName\n\tif public.FileExists(supplierPath) {\n\t\treturn errors.New(\"supplier already exists\")\n\t}\n\n\tsupplier := Supplier{\n\t\tSupplierTitle:   supplierTitle,\n\t\tSupplierName:    supplierName,\n\t\tBaseUrl:         baseUrl,\n\t\tBaseUrlExample:  baseUrl,\n\t\tIsUseUrlExample: false,\n\t\tApiKey:          apiKey,\n\t\tHome:            \"\",","sourceCodeStart":573,"sourceCodeEnd":609,"githubUrl":"https://github.com/Billionmail/BillionMail/blob/fc36c76c050c3775c5e899faf7403cf0262d2744/core/internal/service/askai/supplier.go#L573-L609","documentation":"SetModelStatus scans the supplier's models.json for a matching ModelId and returns this error when no entry matches. The models file exists and is readable; the requested modelId simply is not in the list.","triggerScenarios":"SetModelStatus(supplierName, modelId, status) with a modelId that is misspelled, was removed, or belongs to a different supplier than the one passed.","commonSituations":"Renamed/deprecated model IDs (e.g. vendor renamed a model); hard-coded modelId strings that drifted; passing a model that exists on another supplier.","solutions":["Call GetModelList(supplierName) and confirm the exact ModelId before calling SetModelStatus","Check for typos or trailing whitespace in the modelId argument","Verify you are targeting the correct supplierName"],"exampleFix":"// before: guessing a model id\nerr := SetModelStatus(\"openai\", \"gpt4-turbo\", false)\n\n// after: resolve the real id first\nmodels := GetModelList(\"openai\")\nfor _, m := range models {\n    if strings.Contains(m.ModelId, \"gpt-4\") {\n        err := SetModelStatus(\"openai\", m.ModelId, false)\n    }\n}","handlingStrategy":"validation","validationCode":"func modelExists(supplierName, modelId string) bool {\n    for _, m := range GetModelList(supplierName) {\n        if m.ModelId == modelId { return true }\n    }\n    return false\n}\n// guard: if !modelExists(supplier, id) { skip }","typeGuard":"func findModel(supplierName, modelId string) *Model {\n    for i, m := range GetModelList(supplierName) {\n        if m.ModelId == modelId { return &GetModelList(supplierName)[i] }\n    }\n    return nil\n}","tryCatchPattern":"if err := SetModelStatus(supplier, modelId, status); err != nil {\n    if strings.Contains(err.Error(), \"model not found\") {\n        // refresh model list or skip unknown id\n    } else { return err }\n}","preventionTips":["Always source modelIds from GetModelList, never hard-code strings","Refresh model lists after provider deprecations","Trim and lowercase-compare ids when matching user input"],"tags":["configuration","model-lookup","ai-supplier"],"backgroundTag":"model-not-found","analyzedSha":"fc36c76c050c3775c5e899faf7403cf0262d2744","analyzedAt":"2026-09-05T21:28:54.019Z","contentChangedAt":"2026-09-05T21:28:54.019Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}