Skip to content
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

Error: 'from' parameter is missing with CSV file attachment #245

Open
Jilson opened this issue Sep 5, 2019 · 2 comments
Open

Error: 'from' parameter is missing with CSV file attachment #245

Jilson opened this issue Sep 5, 2019 · 2 comments

Comments

@Jilson
Copy link

Jilson commented Sep 5, 2019

  1. What version of the module is the issue happening on? Does the issue happen on latest version?
    yes
  2. What platform and Node.js version? (For example Node.js 6.9.1 on Mac OS X)
    Node 12.6.0 on Windows 10

I am totally stumped by an error I am receiving while sending an attachment. I have a function I run after generating a csv file from a number of API calls which sends that file as an attachment.

The function is simple, just takes the attachment filepath and text of the message

const sendEmail = (attachment, text) => {

    let data = {
        from,
        to,
        subject,
        text,
        attachment
    }

    mailgun.messages().send(data, (error, body) => {
        if(error) {
            console.log(error);
        } else {
            console.log(body);
            console.log('email sent')
        }
    });
}

When this function runs I have an error

Error: 'from' parameter is missing
at IncomingMessage. (C:\Users\jwils\Code\sycle-reporting\node_modules\mailgun-js\lib\request.js:327:17)
at IncomingMessage.emit (events.js:208:15)
at endReadableNT (_stream_readable.js:1154:12)
at processTicksAndRejections (internal/process/task_queues.js:77:11) {
statusCode: 400
}

I am defining the from value in another variable, and the function works perfectly fine without an attachment. Once I try and send this file I receive the 'from" parameter missing, even though that isn't a missing parameter.

I have been able to send a file with this function under different circumstances, but when I do get this error there is no way of identifying the actual cause from the error message.

Are there any insights into sending csv files? I tried using the mailgun.Attachment class with no success either. I am totally stumped, and don't know where to move from here.

I have been able to send a blank .txt file, but the csv's seem to fail.

I appreciate any information into this specific error message.

Thank you,
Julian

@Jilson
Copy link
Author

Jilson commented Sep 5, 2019

I determined the error is actually that the attachment file did not exist at the time of the email sending. I had a race condition in my csv generation which caused the email to fail to send as the attachment was still writing to disk when it tried to send the email.

Ideally this error message would mention the actual missing parameter.

@jankney2
Copy link

Thanks for this explanation @Jilson. I agree that the error message is misleading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants