Tencent/WeKnora · error

failed to copy file in MinIO: %w

Error message

failed to copy file in MinIO: %w

What it means

MinIO server-side CopyObject failed while duplicating the source object to the new knowledge-owned destination key, so the destination object was not created; permissions, source availability, or server errors are wrapped in the cause.

Source

Thrown at internal/application/service/file/minio.go:194

// server-side CopyObject (no data leaves MinIO). The destination uses the same
// layout as SaveFile. Returns ErrCrossBackendCopy when srcPath is not a minio:// path.
func (s *minioFileService) CopyFile(ctx context.Context,
	srcPath string, tenantID uint64, knowledgeID string,
) (string, error) {
	srcKey, err := s.parseMinioFilePath(srcPath)
	if err != nil {
		return "", fmt.Errorf("minio copy rejected source %q: %w", srcPath, ErrCrossBackendCopy)
	}

	ext := filepath.Ext(srcPath)
	destKey := fmt.Sprintf("%d/%s/%s%s", tenantID, knowledgeID, uuid.New().String(), ext)

	_, err = s.client.CopyObject(ctx,
		minio.CopyDestOptions{Bucket: s.bucketName, Object: destKey},
		minio.CopySrcOptions{Bucket: s.bucketName, Object: srcKey},
	)
	if err != nil {
		return "", fmt.Errorf("failed to copy file in MinIO: %w", err)
	}

	newPath := fmt.Sprintf("minio://%s/%s", s.bucketName, destKey)
	logger.Infof(ctx, "Copied MinIO object %s to %s", srcPath, newPath)
	return newPath, nil
}

// SaveBytes saves bytes data to MinIO and returns the file path
// temp parameter is ignored for MinIO (no auto-expiration support in this implementation)
func (s *minioFileService) SaveBytes(ctx context.Context, data []byte, tenantID uint64, fileName string, temp bool) (string, error) {
	safeName, err := utils.SafeFileName(fileName)
	if err != nil {
		return "", fmt.Errorf("invalid file name: %w", err)
	}
	ext := filepath.Ext(safeName)
	objectName := fmt.Sprintf("%d/exports/%s%s", tenantID, uuid.New().String(), ext)

	// Upload bytes to MinIO

View on GitHub (pinned to 988cbb0330)

Solutions

  1. Check copy permissions on both source and destination
  2. Verify the source object still exists
  3. Retry on transient MinIO errors
Defensive patterns

Strategy: retry

When it happens

Trigger: Thrown at internal/application/service/file/minio.go:194 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/6ba8e7e294ba5755. Report an issue: GitHub.