Skip to content

Commit 50e93e4

Browse files
committed
fix: ensure valid class is checked before validation in document processing
1 parent 570c891 commit 50e93e4

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

apps/knowledge/serializers/document.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ def is_valid(self, *, document: Document = None):
134134
if 'meta' in self.data and self.data.get('meta') is not None and self.data.get('meta') != {}:
135135
knowledge_meta_valid_map = self.get_meta_valid_map()
136136
valid_class = knowledge_meta_valid_map.get(document.type)
137-
valid_class(data=self.data.get('meta')).is_valid(raise_exception=True)
137+
if valid_class is not None:
138+
valid_class(data=self.data.get('meta')).is_valid(raise_exception=True)
138139

139140

140141
class DocumentSplitRequest(serializers.Serializer):

ui/src/views/document/component/ImportDocumentDialog.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ const open = (row: any, list: Array<string>) => {
178178
hit_handling_method: row.hit_handling_method,
179179
directly_return_similarity: row.directly_return_similarity,
180180
...row.meta,
181+
meta: row.meta,
181182
}
182183
isImport.value = false
183184
} else if (list) {
@@ -212,9 +213,13 @@ const submit = async (formEl: FormInstance | undefined) => {
212213
const obj = {
213214
hit_handling_method: form.value.hit_handling_method,
214215
directly_return_similarity: form.value.directly_return_similarity,
216+
// 飞书文档需要传递meta信息,不能被页面上的form覆盖
215217
meta: {
216-
source_url: form.value.source_url,
217-
selector: form.value.selector,
218+
...form.value.meta,
219+
...{
220+
source_url: form.value.source_url,
221+
selector: form.value.selector,
222+
}
218223
},
219224
}
220225
loadSharedApi({ type: 'document', systemType: apiType.value })

0 commit comments

Comments
 (0)