Closed gnaaruag closed 4 months ago
[!WARNING]
Rate limit exceeded
@gnaaruag has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 14 minutes and 53 seconds before requesting another review.
How to resolve this issue?
After the wait time has elapsed, a review can be triggered using the `@coderabbitai review` command as a PR comment. Alternatively, push new commits to this PR. We recommend that you space out your commits to avoid hitting the rate limit.How do rate limits work?
CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our [FAQ](https://coderabbit.ai/docs/faq) for further information.Commits
Files that changed from the base of the PR and between 18c06482636c1c5debc317bb4691f7f70043270d and 66c734b5a960afbd5d80e14942093d026a762c92.
The changes primarily focus on enhancing file upload functionality by checking for empty file uploads, updating interceptor handling, expanding the file interface, and adding comprehensive tests. Additionally, the contribution guidelines have been significantly restructured for clarity. This ensures better resource management, security, data integrity, and developer guidance.
Files/Paths | Change Summary |
---|---|
...file-upload.controller.ts | Added a check for file size being zero before allowing file upload. |
...file-upload.interceptor.ts | Enhanced the interceptor to handle request object modifications. |
...file-upload.interface.ts | Added size and buffer properties to the MultipartFile interface. |
.../app.e2e-spec.ts | Imported fs and path modules, added tests for file upload, including handling empty files, and performed cleanup. |
CONTRIBUTING.md | Restructured and expanded with detailed guidelines on contributing, including new subsections and instructions. |
```mermaid
sequenceDiagram
participant Client as Client
participant Controller as FileUploadController
participant Interceptor as FastifyFileInterceptor
participant Service as FileService
Client->>+Interceptor: Upload File Request
Interceptor->>+Interceptor: Check for request.raw
Interceptor-->>Client: Error if request.raw is falsy
Interceptor-->>Controller: Continue
Controller->>+Service: Check file size
Service-->>Controller: Return error if file is empty
Controller-->>Client: Error if file is empty
Controller->>Client: Success if file is valid
Objective | Addressed | Explanation |
---|---|---|
Add check for empty file upload (156) | β | |
Write tests for file upload feature (149) | β |
In bytes and code, the changes flow, No empty files can now slip by, Tests ensure uploads fly, Contributions clearer, shine in glow. πΆβ¨ A rabbit's charm in every row. ππ οΈ
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?
Checklist
Make sure you have
@nestjs/swagger
decorators wherever requiredDescription
file-upload.controller.ts
inpackages/common/src
process.env.STORAGE_MODE
size
andbuffer
to theMultipartInterface
. (this allows us to have access to size of file and its Buffer contents; needed for empty file check)file-upload.interceptor
the linerequest.raw = request.raw || request;
allows for valid request body to pass throughSteps to test
to test manually create a post request to
/file/upload-file
test with empty file and non empty file via
multipart/form-data
to run automated test navigate to
samples/06-file-upload
and runnpm run test:e2e
fixes #156 fixes #149
Summary by CodeRabbit
New Features
Bug Fixes
request.raw
could be falsy.Documentation
CONTRIBUTING.md
with detailed guidelines and a pre-commit checklist.Tests