From 69702c4700b36075a9c2ce05065be887111d6fc4 Mon Sep 17 00:00:00 2001 From: salvacybersec Date: Mon, 10 Nov 2025 23:45:38 +0300 Subject: [PATCH] fix: Correct database field names in Ollama template creation The bug was in field mapping when saving AI-generated templates: - Changed 'type' to 'template_type' (correct column name) - Changed 'body_template' to 'body_html' (correct column name) This fixes the 400 Bad Request validation error: 'notNull Violation: MailTemplate.template_type cannot be null' Now AI template generation works correctly. --- backend/src/controllers/ollama.controller.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/controllers/ollama.controller.js b/backend/src/controllers/ollama.controller.js index 62f7e1f..6670d70 100644 --- a/backend/src/controllers/ollama.controller.js +++ b/backend/src/controllers/ollama.controller.js @@ -121,9 +121,9 @@ exports.generateTemplate = async (req, res, next) => { if (template_name && template_type) { savedTemplate = await MailTemplate.create({ name: template_name, - type: template_type, + template_type: template_type, // Fixed: was 'type', should be 'template_type' subject_template: templateData.subject_template, - body_template: templateData.body_template, + body_html: templateData.body_template, // Fixed: was 'body_template', should be 'body_html' description: `AI tarafından oluşturuldu - ${scenario}`, });