-
Notifications
You must be signed in to change notification settings - Fork 50.9k
fix(EmailSend Node): Support binary data expressions in attachments #22257
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
base: master
Are you sure you want to change the base?
Conversation
Fixes n8n-io#20832 Users can now use expressions like ={{ $('NodeName').item.binary.data }} in the attachments parameter, in addition to the existing comma-separated string format. Changes: - Enhanced attachment processing to handle string, IBinaryData object, or array - Updated EmailSendOptions type to accept string | IBinaryData | IBinaryData[] - Added comprehensive unit tests (12 tests) covering backward compatibility and new expression functionality - Maintained full backward compatibility with existing workflows
|
|
|
Hey @nsouzaco, Thank you for your contribution. We appreciate the time and effort you’ve taken to submit this pull request. Before we can proceed, please ensure the following: Regarding new nodes: If your node integrates with an AI service that you own or represent, please email [email protected] and we will be happy to discuss the best approach. About review timelines: Thank you again for contributing to n8n. |
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.
1 issue found across 3 files
Prompt for AI agents (all 1 issues)
Understand the root cause of the following 1 issues and fix them.
<file name="packages/nodes-base/nodes/EmailSend/v2/send.operation.ts">
<violation number="1" location="packages/nodes-base/nodes/EmailSend/v2/send.operation.ts:240">
Expression-based attachments remain disabled because the new handling only runs when the current item already has binary data; drop the `item.binary` guard so IBinaryData objects returned from expressions are processed.</violation>
</file>
Since this is your first cubic review, here's how it works:
- cubic automatically reviews your code and comments on bugs and improvements
- Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
- Ask questions if you need clarification on any suggestion
Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR
|
|
||
| for (const propertyName of attachmentProperties) { | ||
| const binaryData = this.helpers.assertBinaryData(itemIndex, propertyName); | ||
| // Handle both string property names and expression-resolved binary data |
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.
Expression-based attachments remain disabled because the new handling only runs when the current item already has binary data; drop the item.binary guard so IBinaryData objects returned from expressions are processed.
Prompt for AI agents
Address the following comment on packages/nodes-base/nodes/EmailSend/v2/send.operation.ts at line 240:
<comment>Expression-based attachments remain disabled because the new handling only runs when the current item already has binary data; drop the `item.binary` guard so IBinaryData objects returned from expressions are processed.</comment>
<file context>
@@ -235,18 +236,44 @@ export async function execute(this: IExecuteFunctions): Promise<INodeExecutionDa
- for (const propertyName of attachmentProperties) {
- const binaryData = this.helpers.assertBinaryData(itemIndex, propertyName);
+ // Handle both string property names and expression-resolved binary data
+ let attachmentItems: Array<string | IBinaryData> = [];
+
</file context>
Fixes #20832
Users can now use expressions like ={{ $('NodeName').item.binary.data }} in the attachments parameter, in addition to the existing comma-separated string format.
Changes:
Summary
Fixes a bug where users cannot use expressions to reference binary data from other nodes in the EmailSend node's attachments parameter. Previously, only comma-separated string property names were supported (e.g.,
"data, file1"). Now users can also use expressions like={{ $('Read File').item.binary.data }}to dynamically reference binary data.What changed
string | IBinaryData | IBinaryData[]How to test
={{ $('Read/Write Files from Disk').item.binary.data }}Before this fix: Attachment would not be sent (expression resolved to object, code expected string)
After this fix: Attachment is correctly attached to the email
Test Coverage
"data","data, file1, file2")Related Linear tickets, Github issues, and Community forum posts
Fixes #20832
Linear: https://linear.app/n8n/issue/GHC-5047
Review / Merge checklist
release/backport(not applicable - this is not an urgent fix)Additional Notes
Breaking Changes: None - fully backward compatible
Files Changed:
packages/nodes-base/nodes/EmailSend/v2/send.operation.ts- Core fixpackages/nodes-base/nodes/EmailSend/v2/utils.ts- Type definitionspackages/nodes-base/nodes/EmailSend/test/v2/send.operation.test.ts- Test coverage (NEW)Code Quality:
ts-ignoreusage