refactor: Unify binary-data assertion across all nodes (no-changelog) (#5624)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2023-03-06 17:33:32 +01:00
committed by GitHub
parent 01a2160b3b
commit 5eb0d52459
69 changed files with 411 additions and 1573 deletions

View File

@@ -508,18 +508,10 @@ export async function prepareEmailAttachments(
if (attachments && !isEmpty(attachments)) {
for (const { property } of attachments) {
for (const name of (property as string).split(',')) {
if (!items[itemIndex].binary || items[itemIndex].binary![name] === undefined) {
const description = `This node has no input field called '${name}' `;
throw new NodeOperationError(this.getNode(), 'Attachment not found', {
description,
itemIndex,
});
}
const binaryData = items[itemIndex].binary![name];
const binaryData = this.helpers.assertBinaryData(itemIndex, name);
const binaryDataBuffer = await this.helpers.getBinaryDataBuffer(itemIndex, name);
if (!items[itemIndex].binary![name] || !Buffer.isBuffer(binaryDataBuffer)) {
if (!Buffer.isBuffer(binaryDataBuffer)) {
const description = `The input field '${name}' doesn't contain an attachment. Please make sure you specify a field containing binary data`;
throw new NodeOperationError(this.getNode(), 'Attachment not found', {
description,