-
-
Notifications
You must be signed in to change notification settings - Fork 67
fix: ensure manifest file_size is updated #1466
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
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. 📝 WalkthroughWalkthroughThe manifest creation trigger now treats zero file sizes as retryable errors (logs id and s3_path then throws), and otherwise always updates the manifest's Changes
Sequence Diagram(s)sequenceDiagram
participant Trigger as "Manifest Create Trigger"
participant Storage as "Object Storage (S3)"
participant DB as "Database"
participant Logger as "Logger"
Trigger->>Storage: fetch object metadata / size (s3_path)
Storage-->>Trigger: return size
alt size == 0
Trigger->>Logger: log retryable zero-size (id, s3_path)
Trigger-->>DB: throw file_size_zero (retry)
else size > 0
Trigger->>DB: update manifest.file_size = size
DB-->>Trigger: update result / error
alt update error
Trigger->>Logger: log manifest_update_failed (record, updateError)
Trigger-->>DB: throw manifest_update_failed
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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
🤖 Fix all issues with AI agents
In `@supabase/functions/_backend/triggers/on_manifest_create.ts`:
- Around line 26-28: The updateError branch currently only logs and returns
success, swallowing DB errors; change the handler in on_manifest_create so that
when updateError is truthy you log with cloudlog (including requestId via
c.get('requestId')) and then throw the updateError (or a new Error wrapping it)
to force the queue to retry; also add braces around the if (updateError) block
since it will contain multiple statements.
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.
Pull request overview
This PR modifies the on_manifest_create trigger to handle cases where S3's getSize returns 0 by throwing an error to trigger queue retry, instead of silently skipping the file_size update.
Changes:
- Inverted the conditional logic to explicitly check for
size === 0and throw an error for queue retry - Database update now executes unconditionally when size > 0 (previously was inside a conditional block)
- Added logging when getSize returns 0 before triggering retry
| if (updateError) | ||
| cloudlog({ requestId: c.get('requestId'), message: 'error update manifest size', error: updateError }) |
Copilot
AI
Jan 19, 2026
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.
When the database update fails (updateError is truthy), the error is logged but the function continues and returns success (c.json(BRES)). This could leave the database in an inconsistent state where the manifest record exists but the file_size was not updated. Consider throwing an error when updateError is truthy to ensure the queue retries the operation until the database update succeeds.
| if (updateError) | |
| cloudlog({ requestId: c.get('requestId'), message: 'error update manifest size', error: updateError }) | |
| if (updateError) { | |
| cloudlog({ requestId: c.get('requestId'), message: 'error update manifest size', error: updateError }) | |
| throw simpleError('manifest_update_failed', 'Failed to update manifest file_size', { record, updateError }) | |
| } |
| if (size === 0) { | ||
| cloudlog({ requestId: c.get('requestId'), message: 'getSize returned 0, will retry', id: record.id, s3_path: record.s3_path }) | ||
| throw simpleError('file_size_zero', 'File size is 0, retrying', { record }) | ||
| } |
Copilot
AI
Jan 19, 2026
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.
The current implementation will cause an infinite retry loop if a manifest file legitimately has a size of 0 bytes. While such files might be rare, they are technically valid. The getSize function returns 0 both when there's an error fetching the size (line 123 in s3.ts) and when file.size is actually 0 (line 119 in s3.ts). Consider adding a retry counter or maximum retry limit to prevent infinite loops, or differentiate between "file not ready yet" (should retry) vs "file is actually 0 bytes" (should accept and update).
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.
@copilot queue system who call this function has already the max retry
| if (size === 0) { | ||
| cloudlog({ requestId: c.get('requestId'), message: 'getSize returned 0, will retry', id: record.id, s3_path: record.s3_path }) | ||
| throw simpleError('file_size_zero', 'File size is 0, retrying', { record }) | ||
| } |
Copilot
AI
Jan 19, 2026
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.
The new size=0 retry behavior lacks test coverage. The existing test in tests/trigger-error-cases.test.ts only covers missing app_version_id or s3_path validation. Consider adding test cases for: 1) when getSize returns 0 (should return 400 with 'file_size_zero' error), and 2) when getSize returns a valid size > 0 (should successfully update the database).
The on_manifest_create trigger was skipping the database update when getSize returned 0, causing file_size to remain 0 in production. Now it throws an error on size=0 to trigger queue retry, ensuring the update always happens when a valid size is available. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
e751909 to
03e0006
Compare
Address review feedback: when updateError occurs, throw simpleError instead of just logging so the queue can retry the operation. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|



Summary
Fixed on_manifest_create trigger to ensure file_size is always updated in the database. Previously, when getSize returned 0, the update was skipped, leaving file_size as 0 in production. Now it throws an error to trigger queue retry.
Test plan
Checklist
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.