{"record":{"id":"ec63190d0e5b779c","repo":"Tencent/WeKnora","slug":"failed-to-delete-file-w-ec6319","errorCode":null,"errorMessage":"failed to delete file: %w","messagePattern":"failed to delete file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/application/service/file/minio.go","lineNumber":170,"sourceCode":"\t\treturn nil, err\n\t}\n\tobj, err := s.client.GetObject(ctx, s.bucketName, objectName, minio.GetObjectOptions{})\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to get file from MinIO: %w\", err)\n\t}\n\treturn obj, nil\n}\n\n// DeleteFile deletes a file\nfunc (s *minioFileService) DeleteFile(ctx context.Context, filePath string) error {\n\tobjectName, err := s.parseMinioFilePath(filePath)\n\tif err != nil {\n\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","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/service/file/minio.go#L152-L188","documentation":"Storage error in minioFileService.DeleteFile: the RemoveObject call (with GovernanceBypass) against the parsed object key failed. The %w preserves the MinIO SDK error (permissions, missing bucket, network); malformed minio:// paths are caught earlier by parseMinioFilePath and never reach this line.","triggerScenarios":"Thrown at internal/application/service/file/minio.go:170 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check delete permissions and any object-lock/retention settings","Verify MinIO health from the wrapped error","Retry so orphans do not accumulate"],"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"}