{"record":{"id":"6ba8e7e294ba5755","repo":"Tencent/WeKnora","slug":"failed-to-copy-file-in-minio-w","errorCode":null,"errorMessage":"failed to copy file in MinIO: %w","messagePattern":"failed to copy file in MinIO: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/application/service/file/minio.go","lineNumber":194,"sourceCode":"// server-side CopyObject (no data leaves MinIO). The destination uses the same\n// layout as SaveFile. Returns ErrCrossBackendCopy when srcPath is not a minio:// path.\nfunc (s *minioFileService) CopyFile(ctx context.Context,\n\tsrcPath string, tenantID uint64, knowledgeID string,\n) (string, error) {\n\tsrcKey, err := s.parseMinioFilePath(srcPath)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"minio copy rejected source %q: %w\", srcPath, ErrCrossBackendCopy)\n\t}\n\n\text := filepath.Ext(srcPath)\n\tdestKey := fmt.Sprintf(\"%d/%s/%s%s\", tenantID, knowledgeID, uuid.New().String(), ext)\n\n\t_, err = s.client.CopyObject(ctx,\n\t\tminio.CopyDestOptions{Bucket: s.bucketName, Object: destKey},\n\t\tminio.CopySrcOptions{Bucket: s.bucketName, Object: srcKey},\n\t)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to copy file in MinIO: %w\", err)\n\t}\n\n\tnewPath := fmt.Sprintf(\"minio://%s/%s\", s.bucketName, destKey)\n\tlogger.Infof(ctx, \"Copied MinIO object %s to %s\", srcPath, newPath)\n\treturn newPath, nil\n}\n\n// SaveBytes saves bytes data to MinIO and returns the file path\n// temp parameter is ignored for MinIO (no auto-expiration support in this implementation)\nfunc (s *minioFileService) SaveBytes(ctx context.Context, data []byte, tenantID uint64, fileName string, temp bool) (string, error) {\n\tsafeName, err := utils.SafeFileName(fileName)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"invalid file name: %w\", err)\n\t}\n\text := filepath.Ext(safeName)\n\tobjectName := fmt.Sprintf(\"%d/exports/%s%s\", tenantID, uuid.New().String(), ext)\n\n\t// Upload bytes to MinIO","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/service/file/minio.go#L176-L212","documentation":"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.","triggerScenarios":"Thrown at internal/application/service/file/minio.go:194 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check copy permissions on both source and destination","Verify the source object still exists","Retry on transient MinIO errors"],"exampleFix":null,"handlingStrategy":"retry","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"}