Tencent/WeKnora · error
failed to delete file: %w
Error message
failed to delete file: %w
What it means
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.
Source
Thrown at internal/application/service/file/minio.go:170
return nil, err
}
obj, err := s.client.GetObject(ctx, s.bucketName, objectName, minio.GetObjectOptions{})
if err != nil {
return nil, fmt.Errorf("failed to get file from MinIO: %w", err)
}
return obj, nil
}
// DeleteFile deletes a file
func (s *minioFileService) DeleteFile(ctx context.Context, filePath string) error {
objectName, err := s.parseMinioFilePath(filePath)
if err != nil {
return err
}
if err := s.client.RemoveObject(ctx, s.bucketName, objectName, minio.RemoveObjectOptions{
GovernanceBypass: true,
}); err != nil {
return fmt.Errorf("failed to delete file: %w", err)
}
return nil
}
// CopyFile copies an existing MinIO object to a new knowledge-owned object using a
// 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)
View on GitHub (pinned to 988cbb0330)
Solutions
- Check delete permissions and any object-lock/retention settings
- Verify MinIO health from the wrapped error
- Retry so orphans do not accumulate
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at internal/application/service/file/minio.go:170 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/ec63190d0e5b779c.
Report an issue: GitHub.