{"record":{"id":"2fcba1f526de1dbc","repo":"Tencent/WeKnora","slug":"minio-copy-rejected-source-q-w","errorCode":null,"errorMessage":"minio copy rejected source %q: %w","messagePattern":"minio copy rejected source %q: %w","errorType":"validation","errorClass":"ErrCrossBackendCopy","httpStatus":null,"severity":"error","filePath":"internal/application/service/file/minio.go","lineNumber":183,"sourceCode":"\t\treturn err\n\t}\n\tif err := s.client.RemoveObject(ctx, s.bucketName, objectName, minio.RemoveObjectOptions{\n\t\tGovernanceBypass: true,\n\t}); err != nil {\n\t\treturn fmt.Errorf(\"failed to delete file: %w\", err)\n\t}\n\treturn nil\n}\n\n// CopyFile copies an existing MinIO object to a new knowledge-owned object using a\n// 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","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/service/file/minio.go#L165-L201","documentation":"Cross-backend copy guard: the source path failed to parse as a minio:// path, so it belongs to a different storage backend; the copy is rejected with the ErrCrossBackendCopy sentinel because a server-side MinIO CopyObject is impossible across backends.","triggerScenarios":"Thrown at internal/application/service/file/minio.go:183 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Route the copy to the backend that owns the source path","Download from the source backend and re-upload to MinIO if cross-backend copy is required","Check for the sentinel with errors.Is in callers"],"exampleFix":null,"handlingStrategy":"fallback","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"}