{"record":{"id":"0b3f2ff87482169c","repo":"Billionmail/BillionMail","slug":"content-cannot-be-empty","errorCode":null,"errorMessage":"Content cannot be empty","messagePattern":"Content cannot be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"core/internal/service/askai/chat.go","lineNumber":246,"sourceCode":"\n\treturn chatList, nil\n}\n\n// GetChatInfo retrieves the chat information for a given chat ID\n// This function should handle the logic for loading the chat information and return the ChatInfo struct and any error encountered\nfunc GetChatInfo(chatId string) (*ChatInfo, error) {\n\tchatInfo, err := GetChat(chatId)\n\tif err != nil {\n\t\treturn nil, err\n\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","sourceCodeStart":228,"sourceCodeEnd":264,"githubUrl":"https://github.com/Billionmail/BillionMail/blob/fc36c76c050c3775c5e899faf7403cf0262d2744/core/internal/service/askai/chat.go#L228-L264","documentation":"Chat validates its content argument and rejects whitespace-only or empty messages before doing any supplier/model lookup. This prevents sending empty prompts to the AI supplier. The message is a plain errors.New value, so callers must compare by string, not errors.Is with a sentinel.","triggerScenarios":"Calling Chat(ctx, chatId, supplierName, modelId, \"\" or \"   \", isText) — content trims to empty via strings.TrimSpace.","commonSituations":"Frontend sends an empty input box submission; a pipeline passes a variable that was never populated; trimming user input upstream leaves an empty string that is still forwarded to Chat.","solutions":["Check content length after trimming before calling Chat and show a user-facing message instead","Ensure the UI blocks submission of empty/whitespace-only messages","If content comes from another function, verify that function's return value is non-empty"],"exampleFix":"// before\nerr := askai.Chat(ctx, chatId, supplier, model, userInput, true)\n// after\ntext := strings.TrimSpace(userInput)\nif text == \"\" {\n    return errors.New(\"please enter a message\")\n}\nerr := askai.Chat(ctx, chatId, supplier, model, text, true)","handlingStrategy":"validation","validationCode":"if strings.TrimSpace(content) == \"\" {\n    return errors.New(\"message is empty\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Trim and check user input at the UI/API boundary","Disable send buttons on empty input","Never forward unvalidated upstream variables into Chat"],"tags":["validation","askai","empty-input"],"backgroundTag":"empty-input-validation","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"}