{"record":{"id":"9bc494e1803d68cb","repo":"Tencent/WeKnora","slug":"failed-to-marshal-entries-w","errorCode":null,"errorMessage":"failed to marshal entries: %w","messagePattern":"failed to marshal entries: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/application/service/knowledge_faq_import.go","lineNumber":153,"sourceCode":"\t\tDryRun:      payload.DryRun,\n\t\tEnqueuedAt:  enqueuedAt,\n\t\tInstanceID:  instanceID,\n\t\tInitiator:   types.TaskInitiatorFromContext(ctx),\n\t}\n\n\t// 阈值：超过 200 条或序列化后超过 50KB 时使用对象存储\n\tconst (\n\t\tentryCountThreshold  = 200\n\t\tpayloadSizeThreshold = 50 * 1024 // 50KB\n\t)\n\n\tentryCount := len(payload.Entries)\n\tif entryCount > entryCountThreshold {\n\t\t// 数据量较大，上传到对象存储\n\t\tentriesData, err := json.Marshal(payload.Entries)\n\t\tif err != nil {\n\t\t\tlogger.Errorf(ctx, \"Failed to marshal FAQ entries: %v\", err)\n\t\t\treturn \"\", fmt.Errorf(\"failed to marshal entries: %w\", err)\n\t\t}\n\n\t\tlogger.Infof(ctx, \"FAQ entries size: %d bytes, uploading to object storage\", len(entriesData))\n\n\t\t// 上传到私有桶（主桶），任务处理完成后清理\n\t\tfileName := fmt.Sprintf(\"faq_import_entries_%s_%d.json\", taskID, enqueuedAt)\n\t\tentriesURL, err := s.fileSvc.SaveBytes(ctx, entriesData, tenantID, fileName, false)\n\t\tif err != nil {\n\t\t\tlogger.Errorf(ctx, \"Failed to upload FAQ entries to object storage: %v\", err)\n\t\t\treturn \"\", fmt.Errorf(\"failed to upload entries: %w\", err)\n\t\t}\n\n\t\tlogger.Infof(ctx, \"FAQ entries uploaded to: %s\", entriesURL)\n\t\ttaskPayload.EntriesURL = entriesURL\n\t\ttaskPayload.EntryCount = entryCount\n\t} else {\n\t\t// 数据量较小，直接存储在 payload 中\n\t\ttaskPayload.Entries = payload.Entries","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/service/knowledge_faq_import.go#L135-L171","documentation":"Thrown when json.Marshal fails to serialize the FAQ entries payload before uploading it to object storage (large-batch path, >200 entries). Only fires if an entry contains a value Go's encoding/json cannot encode, e.g. a channel, func, or cyclic reference in FAQEntryPayload.","triggerScenarios":"Thrown at internal/application/service/knowledge_faq_import.go:153 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the wrapped marshal error to find the offending entry/field","Ensure FAQEntryPayload only contains JSON-serializable types (strings, ints, bools, slices)","Reject malformed entries at API validation time before import"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}