-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
fix(builders): handle 0 as valid attachment ID #11330
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
fix(builders): handle 0 as valid attachment ID #11330
Conversation
Fixes discordjs#11314 The AttachmentBuilder.getRawFile() method was using a falsy check that treated 0 as invalid. Changed to use the 'in' operator to properly check for the existence of the id property.
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #11330 +/- ##
==========================================
+ Coverage 32.45% 38.59% +6.14%
==========================================
Files 369 375 +6
Lines 13611 17528 +3917
Branches 1069 1483 +414
==========================================
+ Hits 4417 6765 +2348
- Misses 9059 10747 +1688
+ Partials 135 16 -119
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Co-authored-by: Jiralite <[email protected]>
didinele
left a 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.
Almeida approved but I insist on their proposed diff.
|
Deployment failed with the following error: |
📝 WalkthroughWalkthroughThe fix corrects how AttachmentBuilder handles id 0, treating it as a valid identifier instead of falsy. Previously, id 0 was treated as falsy, preventing the key field from being included in the RawFile output. The conditional check was updated to explicitly detect undefined values, and a test was added to verify this behavior. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: ASSERTIVE Plan: Pro 📒 Files selected for processing (2)
🔇 Additional comments (2)
Comment |
Description
Fixes #11314
AttachmentBuilder.getRawFile()was using a falsy check (this.data.id ? ...) to determine whether the attachment ID existed.Because
0is a valid ID but is falsy in JavaScript, the method incorrectly treated it as missing, producing an invalid file reference.This PR updates the condition to properly detect the presence of the
idproperty, allowing0to be handled correctly.Changes
this.data.id? ...with a property-existence check:'id' in this.data? ....0generates the expected raw file key (files[0]).Testing
getRawFile()returns'files[0]'when the ID is0.Type of Change