-
Notifications
You must be signed in to change notification settings - Fork 0
Grant grace period on uploads for attachments #371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Warning Rate limit exceeded@devksingh4 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 5 minutes and 52 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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 for further information. 📒 Files selected for processing (2)
WalkthroughTwo files are modified to implement a grace period for attachment deletion. A constant Changes
Sequence DiagramsequenceDiagram
participant Client
participant Handler as roomRequests Handler
participant S3
participant DynamoDB
rect rgb(240, 248, 255)
Note over Handler,DynamoDB: Before: Immediate deletion on S3 NotFound
Client->>Handler: Request (status update / URL retrieval)
Handler->>S3: Fetch attachment
S3-->>Handler: NotFound error
Handler->>DynamoDB: DeleteItem (attachment key)
DynamoDB-->>Handler: Deleted
Handler-->>Client: Error response
end
rect rgb(240, 255, 240)
Note over Handler,DynamoDB: After: Grace period check before deletion
Client->>Handler: Request (status update / URL retrieval)
Handler->>S3: Fetch attachment
S3-->>Handler: NotFound error
Handler->>Handler: Check: createdAt + grace period?
alt Grace period elapsed
Handler->>DynamoDB: UpdateItem (remove attachment key)
DynamoDB-->>Handler: Updated
else Grace period active
Handler->>Handler: Skip deletion
end
Handler-->>Client: Error response
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
Comment |
💰 Infracost reportMonthly estimate generatedThis comment will be updated when code changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
src/api/routes/roomRequests.ts (2)
38-41: Address ESLint warning about file extension.ESLint is flagging the
.jsextension in the import path. Consider removing it for consistency with linting rules.Apply this diff:
import { ROOM_RESERVATION_RETENTION_DAYS, UPLOAD_GRACE_PERIOD_MS, -} from "common/constants.js"; +} from "common/constants";Based on static analysis hints.
686-708: Consider adding logging for observability.The grace period logic would benefit from logging to distinguish between cases where the grace period is still active versus when the DynamoDB reference is being cleaned up. This would help with debugging and monitoring upload issues.
Consider adding log statements like:
if (timeSinceCreation >= UPLOAD_GRACE_PERIOD_MS) { request.log.info( `Grace period elapsed for attachment ${unmarshalled.attachmentS3key}, removing DynamoDB reference` ); // Grace period has passed, delete the attribute from DynamoDB await fastify.dynamoClient.send( // ... existing code ); } else { request.log.info( `Attachment not found but within grace period (${timeSinceCreation}ms / ${UPLOAD_GRACE_PERIOD_MS}ms)` ); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge base: Disabled due to data retention organization setting
📒 Files selected for processing (2)
src/api/routes/roomRequests.ts(2 hunks)src/common/constants.ts(1 hunks)
🧰 Additional context used
🪛 ESLint
src/api/routes/roomRequests.ts
[error] 41-41: Unexpected use of file extension "js" for "common/constants.js"
(import/extensions)
🪛 GitHub Actions: Required Reviews
src/common/constants.ts
[error] 1-1: CI check failed: Base Requirement not satisfied by the existing reviews.
src/api/routes/roomRequests.ts
[error] 1-1: CI check failed: Base Requirement not satisfied by the existing reviews.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Build Application
- GitHub Check: Run Unit Tests
🔇 Additional comments (2)
src/common/constants.ts (1)
6-6: LGTM!The constant is well-named, clearly documented, and the 30-minute grace period is reasonable for handling eventual consistency or upload delays.
src/api/routes/roomRequests.ts (1)
686-708: Review comment is incorrect; no issues found.The codebase has only one location where
HeadObjectCommandis used (attachment download URL retrieval at line 679), making it the only place where S3NotFoundexceptions are caught. The status update path usescreatePresignedPut, which generates presigned upload URLs without validating object existence. The grace period logic is correctly implemented in the sole location where it's needed.Likely an incorrect or invalid review comment.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
48bcc94 to
9c62496
Compare
Summary by CodeRabbit