Tencent/WeKnora · error

failed to marshal manual process payload: %w

Error message

failed to marshal manual process payload: %w

What it means

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.

Source

Thrown at internal/application/service/knowledge_create.go:1132

}

// enqueueManualProcessing enqueues a manual:process Asynq task for async cleanup + re-indexing.
func (s *knowledgeService) enqueueManualProcessing(ctx context.Context,
	knowledge *types.Knowledge, content string, needCleanup bool,
) (string, error) {
	requestID, _ := types.RequestIDFromContext(ctx)
	payload := types.ManualProcessPayload{
		RequestId:       requestID,
		TenantID:        knowledge.TenantID,
		KnowledgeID:     knowledge.ID,
		KnowledgeBaseID: knowledge.KnowledgeBaseID,
		Content:         content,
		NeedCleanup:     needCleanup,
	}
	langfuse.InjectTracing(ctx, &payload)
	payloadBytes, err := json.Marshal(payload)
	if err != nil {
		return "", fmt.Errorf("failed to marshal manual process payload: %w", err)
	}

	task := asynq.NewTask(types.TypeManualProcess, payloadBytes,
		asynq.Queue(types.QueueDefault), asynq.MaxRetry(3), asynq.Timeout(30*time.Minute))
	info, err := s.task.Enqueue(task)
	if err != nil {
		return "", fmt.Errorf("failed to enqueue manual process task: %w", err)
	}
	logger.Infof(ctx, "Enqueued manual process task: knowledge_id=%s, asynq_id=%s", knowledge.ID, info.ID)
	return info.ID, nil
}

// markKnowledgeEnqueueFailed prevents a durable knowledge row from remaining
// indefinitely "pending" when its background processing task was never
// created. The API may still return the row so callers can retry it.
func (s *knowledgeService) markKnowledgeEnqueueFailed(ctx context.Context, knowledge *types.Knowledge) {
	if knowledge == nil {
		return

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Audit ManualProcessPayload field types for JSON compatibility
  2. Add unit test serializing the payload to catch regressions
  3. Fail the API request so the caller knows indexing was not scheduled
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at internal/application/service/knowledge_create.go:1132 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02). Data as JSON: /api/errors/5d283754803e093f. Report an issue: GitHub.