From 6a7d8115d587af624acead4a7baa451a64c018ff Mon Sep 17 00:00:00 2001 From: octo-patch Date: Mon, 20 Apr 2026 11:01:02 +0800 Subject: [PATCH 1/2] fix: change agent_custom_config column type to text to prevent Data too long error (fixes #52) The agent_custom_config column was created without an explicit type annotation, causing GORM to default to a short VARCHAR type. This resulted in 'Error 1406: Data too long for column agent_custom_config' when users configured agents with long custom config content. Changed the GORM tag to use type:text, consistent with the Message, Answer, and ReasoningContent fields in the same struct. AutoMigrate will update the column type in existing databases when MIGRATE_DB_ENABLED=true. --- api/model/message.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/model/message.go b/api/model/message.go index 561fb2f..1d39d0c 100644 --- a/api/model/message.go +++ b/api/model/message.go @@ -21,7 +21,7 @@ type Message struct { ElapsedTime int64 `json:"elapsed_time" gorm:"default:0"` IsStream bool `json:"is_stream" gorm:"default:false"` QuotaContent string `json:"quota_content" gorm:"default:''"` - AgentCustomConfig string `json:"agent_custom_config" gorm:"default:''"` + AgentCustomConfig string `json:"agent_custom_config" gorm:"default:'';type:text"` BaseModel } From 7b6ff25f1952b1c674a0450f259be35bad6b865f Mon Sep 17 00:00:00 2001 From: octo-patch Date: Sat, 25 Apr 2026 12:02:28 +0800 Subject: [PATCH 2/2] fix: handle non-string values in form validator to prevent trim error (fixes #56) When file upload fields (file, array_image, array_audio, array_video, array_file) are used in completion forms, item.value contains File objects, not strings. Calling .trim() on File objects throws "L.trim is not a function" at runtime. Apply the same type-aware validation logic already present in the admin console version: check array length for file types, and use String(val).trim() for array/string types to safely handle any value type. Co-Authored-By: Octopus --- .../src/renderer/main/views/chat/completion/index.vue | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/web/front/src/renderer/main/views/chat/completion/index.vue b/web/front/src/renderer/main/views/chat/completion/index.vue index 01e889b..c74123a 100644 --- a/web/front/src/renderer/main/views/chat/completion/index.vue +++ b/web/front/src/renderer/main/views/chat/completion/index.vue @@ -449,7 +449,14 @@ const imageFile = ref() const validator = (item) => { return (rule, value, callback) => { if (item.required) { - const hasVal = item.value.some((item) => item.trim()) + let hasVal = false + if (['file', 'array_image', 'array_audio', 'array_video', 'array_file'].includes(item.type)) { + hasVal = Array.isArray(item.value) && item.value.length > 0 + } else if (Array.isArray(item.value)) { + hasVal = item.value.some((val) => val && String(val).trim().length > 0) + } else { + hasVal = item.value && String(item.value).trim().length > 0 + } if (hasVal) callback() else callback(new Error(`请添加${item.label}`)) } else {