{"record":{"id":"5d283754803e093f","repo":"Tencent/WeKnora","slug":"failed-to-marshal-manual-process-payload-w","errorCode":null,"errorMessage":"failed to marshal manual process payload: %w","messagePattern":"failed to marshal manual process payload: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/application/service/knowledge_create.go","lineNumber":1132,"sourceCode":"}\n\n// enqueueManualProcessing enqueues a manual:process Asynq task for async cleanup + re-indexing.\nfunc (s *knowledgeService) enqueueManualProcessing(ctx context.Context,\n\tknowledge *types.Knowledge, content string, needCleanup bool,\n) (string, error) {\n\trequestID, _ := types.RequestIDFromContext(ctx)\n\tpayload := types.ManualProcessPayload{\n\t\tRequestId:       requestID,\n\t\tTenantID:        knowledge.TenantID,\n\t\tKnowledgeID:     knowledge.ID,\n\t\tKnowledgeBaseID: knowledge.KnowledgeBaseID,\n\t\tContent:         content,\n\t\tNeedCleanup:     needCleanup,\n\t}\n\tlangfuse.InjectTracing(ctx, &payload)\n\tpayloadBytes, err := json.Marshal(payload)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to marshal manual process payload: %w\", err)\n\t}\n\n\ttask := asynq.NewTask(types.TypeManualProcess, payloadBytes,\n\t\tasynq.Queue(types.QueueDefault), asynq.MaxRetry(3), asynq.Timeout(30*time.Minute))\n\tinfo, err := s.task.Enqueue(task)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to enqueue manual process task: %w\", err)\n\t}\n\tlogger.Infof(ctx, \"Enqueued manual process task: knowledge_id=%s, asynq_id=%s\", knowledge.ID, info.ID)\n\treturn info.ID, nil\n}\n\n// markKnowledgeEnqueueFailed prevents a durable knowledge row from remaining\n// indefinitely \"pending\" when its background processing task was never\n// created. The API may still return the row so callers can retry it.\nfunc (s *knowledgeService) markKnowledgeEnqueueFailed(ctx context.Context, knowledge *types.Knowledge) {\n\tif knowledge == nil {\n\t\treturn","sourceCodeStart":1114,"sourceCodeEnd":1150,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/service/knowledge_create.go#L1114-L1150","documentation":"Serializing the ManualProcessPayload (with injected tracing fields) to JSON failed while enqueueing the async manual-processing task; this only happens if a payload field is not JSON-encodable (e.g. a channel or func slipped in), so the async cleanup/re-index job cannot be created.","triggerScenarios":"Thrown at internal/application/service/knowledge_create.go:1132 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Audit ManualProcessPayload field types for JSON compatibility","Add unit test serializing the payload to catch regressions","Fail the API request so the caller knows indexing was not scheduled"],"exampleFix":null,"handlingStrategy":"validation","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"}