{"record":{"id":"40b74c9e81fa4bfe","repo":"Billionmail/BillionMail","slug":"model-not-found-40b74c","errorCode":null,"errorMessage":"Model not found","messagePattern":"Model not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/internal/service/askai/chat.go","lineNumber":256,"sourceCode":"\t}\n\tchatInfo.Messages = GetMessages(chatId)\n\treturn chatInfo, nil\n}\n\nfunc Chat(ctx context.Context, chatId string, supplierName string, modelId string, content string, isText bool) error {\n\tcontent = strings.TrimSpace(content)\n\tif content == \"\" {\n\t\treturn errors.New(\"Content cannot be empty\")\n\t}\n\n\tsupplierInfo, err := GetSupplierConfig(supplierName)\n\tif err != nil {\n\t\treturn errors.New(\"Supplier not found\")\n\t}\n\n\tmodelInfo := GetModelInfo(supplierName, modelId)\n\tif modelInfo == nil {\n\t\treturn errors.New(\"Model not found\")\n\t}\n\n\t// Check if the chat is already active\n\tchatInfo, err := GetChat(chatId)\n\tif err != nil {\n\t\treturn errors.New(\"Chat not found\")\n\t}\n\t// set the chat information\n\tchatInfo.SupplierName = supplierName\n\tchatInfo.ModelId = modelId\n\terr = SaveChat(chatId, chatInfo)\n\tif err != nil {\n\t\treturn errors.New(\"Failed to save chat\")\n\t}\n\n\tChatStatus[chatId] = true // Set chat status to active\n\tdefer func() {\n\t\tdelete(ChatStatus, chatId) // Ensure chat status is removed after processing","sourceCodeStart":238,"sourceCodeEnd":274,"githubUrl":"https://github.com/Billionmail/BillionMail/blob/fc36c76c050c3775c5e899faf7403cf0262d2744/core/internal/service/askai/chat.go#L238-L274","documentation":"Chat resolves the model via GetModelInfo(supplierName, modelId) and returns this error when it returns nil, meaning the model ID is unknown for that supplier. The client cannot be initialized without model metadata such as MaxTokens.","triggerScenarios":"Calling Chat with a modelId that does not exist under the given supplier (wrong ID, model removed from the supplier's catalog, model listed under a different supplier).","commonSituations":"Supplier deprecated/renamed a model (e.g., GPT model version retirement); hardcoded modelId after switching suppliers; stale chat records pointing at a deleted model entry.","solutions":["Call GetModelInfo(supplierName, modelId) yourself first and confirm it is non-nil","Refresh the supplier's model list and pick a valid modelId","Update stored chat configurations that reference removed models"],"exampleFix":"// before\nerr := askai.Chat(ctx, chatId, supplier, \"gpt-3.5-turbo-0301\", content, true)\n// after\nif askai.GetModelInfo(supplier, \"gpt-4o-mini\") == nil {\n    return errors.New(\"model unavailable for supplier\")\n}\nerr := askai.Chat(ctx, chatId, supplier, \"gpt-4o-mini\", content, true)","handlingStrategy":"validation","validationCode":"if askai.GetModelInfo(supplierName, modelId) == nil {\n    return fmt.Errorf(\"model %q unavailable for supplier %q\", modelId, supplierName)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Populate model dropdowns from the supplier's live model list","Handle supplier model deprecations by refreshing catalogs","Store supplier+model pairs together, never mix across suppliers"],"tags":["askai","model","configuration","lookup-failed"],"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"}