Skip to content

Akash/delete file - #252

Merged
aakashg00 merged 8 commits into
mainfrom
akash/delete-file
Apr 12, 2026
Merged

aakashg00 merged 8 commits into
mainfrom
akash/delete-file

Conversation

@asarode06

Copy link
Copy Markdown
Collaborator

PR requirements

  • Create your S3 Backblaze account and api keys to test deleting files with S3
  • Create your Azure Blob Storage account and api keys to test deleting files with Azure (if this requires payment, DM me and I'll give you BOG Azure credentials)
  • Video demo of using Postman to hit the endpoint and show that files are deleted correctly

Video demo

2026-04-07.04-47-09.mp4

@greptile-apps

greptile-apps Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR implements a file deletion endpoint across the API gateway and file service, supporting both S3/Backblaze and Azure Blob Storage providers. The architecture mirrors existing upload/download patterns and test coverage is solid.

  • The S3 deleteFiles handler does not inspect the Errors array returned by DeleteObjectsCommand. AWS returns HTTP 200 even for partial failures, so silently ignored S3 errors will cause the controller to delete DB records for files that were never actually removed from storage — leaving storage and database out of sync.

Confidence Score: 4/5

One P1 issue must be addressed before merging: S3 partial-deletion errors are silently ignored, risking DB/storage inconsistency.

Score of 4 reflects a single P1 defect in s3_handler.ts where AWS DeleteObjectsCommand partial failures are not checked. All other findings are P2 or stylistic. Fixing the Errors-array check would bring this to 5.

packages/file-service/src/modules/file_transfer/s3_handler.ts — the deleteFiles method must inspect result.Errors after calling DeleteObjectsCommand.

Important Files Changed

Filename Overview
packages/file-service/src/modules/file_transfer/s3_handler.ts Adds deleteFiles using ListObjectVersions + DeleteObjects, but does not check the Errors field in the delete response, risking DB/storage inconsistency on partial failures.
packages/file-service/src/modules/file_transfer/azure_handler.ts Adds deleteFiles using deleteIfExists() per blob; silently ignores missing files (acceptable behavior), correctly wrapped in try/catch.
packages/file-service/src/modules/file_transfer/file_transfer.controller.ts Orchestrates delete by fetching bucket, resolving provider, dispatching to handler, then bulk-deleting DB records; input validation is solid.
packages/api-gateway/src/models/file_delete.dto.ts Well-structured DTO but missing per-element @IsString and @IsNotEmpty validators on fileNames array items.
packages/api-gateway/src/modules/file_delete/file_delete.controller.ts Clean gateway controller that correctly passes API key environment and delegates to the file service via gRPC.
packages/api-gateway/src/modules/file_delete/file_delete.module.ts Standard NestJS module wiring; follows the same pattern as FileUploadModule.
packages/proto/definitions/file.proto Adds DeleteFilesRequest / DeleteFilesResponse messages and deleteFiles RPC; definition is minimal and appropriate.
packages/api-gateway/test/file_delete.e2e-spec.ts Good e2e coverage: auth check, empty bucketName, negative configId, empty fileNames array, and a successful delete flow.
packages/file-service/test/file_delete.e2e-spec.ts Service-level tests cover validation failures and upload-then-delete flows for both S3 and Azure providers.
packages/api-gateway/src/app.module.ts Correctly imports and registers FileDeleteModule.
packages/proto/src/gen/file.ts Auto-generated TypeScript bindings from the updated proto; no manual changes.

Sequence Diagram

sequenceDiagram
    participant Client
    participant GW as API Gateway
    participant FS as File Service
    participant Store as S3 / Azure
    participant DB as File DB Service

    Client->>GW: DELETE /file/delete {bucketName, configId, fileNames}
    GW->>FS: gRPC deleteFiles(request)
    FS->>DB: getBucket(bucketName, configId, configEnv)
    DB-->>FS: bucket (fileProviderName)
    FS->>DB: getProvider(fileProviderName)
    DB-->>FS: provider (type: S3 | AZURE)
    FS->>Store: delete objects (DeleteObjectsCommand OR deleteIfExists)
    Store-->>FS: 200 OK (may include Errors[] on S3)
    FS->>DB: deleteFile × N (Promise.all)
    DB-->>FS: deleted file records
    FS-->>GW: DeleteFilesResponse {bucketName, fileNames}
    GW-->>Client: 200 OK
Loading

Reviews (1): Last reviewed commit: "implemented e2e tests" | Re-trigger Greptile

Comment thread packages/file-service/src/modules/file_transfer/s3_handler.ts Outdated
Comment thread packages/api-gateway/src/models/file_delete.dto.ts

@aakashg00 aakashg00 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@aakashg00
aakashg00 merged commit c397ebf into main Apr 12, 2026
8 of 9 checks passed
@aakashg00
aakashg00 deleted the akash/delete-file branch April 12, 2026 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Spring 2026] Delete files from remote file providers

2 participants