Tencent/WeKnora · error

failed to get file URL: %w

Error message

failed to get file URL: %w

What it means

Thrown inside generateFailedEntriesCSV when fileSvc.GetFileURL fails to mint a download URL for the just-uploaded failed-entries CSV. The file exists but is unreachable via presigned URL; typically a signing/endpoint configuration problem in the file service.

Source

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

		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, "\"", "\"\"") + "\""
	}
	return s
}

// saveFAQImportResultToDatabase 保存FAQ导入结果统计到数据库
func (s *knowledgeService) saveFAQImportResultToDatabase(ctx context.Context,
	payload *types.FAQImportPayload, progress *types.FAQImportProgress, originalTotalEntries int,

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Verify storage endpoint / presign configuration for the temp bucket
  2. Check credentials and clock skew affecting signature validity
  3. Retry; the CSV object itself was already saved and can be re-URLed
Defensive patterns

Strategy: retry

When it happens

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