Tencent/WeKnora · error

failed to save CSV file: %w

Error message

failed to save CSV file: %w

What it means

Thrown inside generateFailedEntriesCSV when fileSvc.SaveBytes fails to upload the CSV of failed FAQ dry-run entries to temporary (auto-expiring) storage. A storage-layer failure; the caller cannot produce a download link for failed rows.

Source

Thrown at internal/application/service/knowledge_faq_import.go:286

		}
		answerAll := "false"
		if entry.AnswerAll {
			answerAll = "true"
		}
		isDisabled := "false"
		if entry.IsDisabled {
			isDisabled = "true"
		}

		buf.WriteString(fmt.Sprintf("%s,%s,%s,%s,%s,%s,%s,%s\n",
			reason, tagName, standardQ, similarQs, negativeQs, answers, answerAll, isDisabled))
	}

	// 上传 CSV 文件到临时存储(会自动过期)
	fileName := fmt.Sprintf("faq_dryrun_failed_%s.csv", taskID)
	filePath, err := s.fileSvc.SaveBytes(ctx, []byte(buf.String()), tenantID, fileName, true)
	if err != nil {
		return "", fmt.Errorf("failed to save CSV file: %w", err)
	}

	// 获取下载 URL
	fileURL, err := s.fileSvc.GetFileURL(ctx, filePath)
	if err != nil {
		return "", fmt.Errorf("failed to get file URL: %w", err)
	}

	logger.Infof(ctx, "Generated failed entries CSV: %s, entries: %d", fileURL, len(failedEntries))
	return fileURL, nil
}

// csvEscape 转义 CSV 字段
func csvEscape(s string) string {
	if strings.ContainsAny(s, ",\"\n\r") {
		// 将内部引号替换为两个引号,并用引号包裹整个字段
		return "\"" + strings.ReplaceAll(s, "\"", "\"\"") + "\""
	}

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Check object storage availability and tenant credentials
  2. Confirm temp-bucket write permissions and expiry policy
  3. Retry the dry run; failed-entry rows also remain in the progress record
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at internal/application/service/knowledge_faq_import.go:286 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/48fe73547b16defe. Report an issue: GitHub.