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

🐛 Bug Report — Runtime APIs Error: "In-Reply-To does not match original Message-ID" for MS Outlook emails #2536

Closed
asimpletune opened this issue Aug 15, 2024 · 8 comments

Comments

@asimpletune
Copy link

Send an email to a CF worker from a MS outlook client and try to reply using the email's Message-ID. This happens with the exact same code from the docs, and then you'll find the following error:

Error: In-Reply-To does not match original Message-ID

@asimpletune
Copy link
Author

I can confirm that prepending a line break to ms outlook message_id's fixes the issue, but it's still a bug.

reply_msg.setHeader('In-Reply-To', `\n ${msg.headers.get('Message-ID')}\n`) // notice the \n

@asimpletune
Copy link
Author

Here is an example message-id that fails

Message-ID:
 <PAXP193MB2314C6F90A60DA909597069AA7802@PAXP193MB2314.EURP193.PROD.OUTLOOK.COM>

This comes from the actual source of an email sent by ms outlook. It looks like there's some line folding that is happening. I'm guessing that on the cloudflare end of things, the string is being compared to the original message exactly. However, the header.get method returns the header value without the folding.

I think the email specs allow folding but that the unfolded text should be treated as one line.

@leurs247
Copy link

leurs247 commented Oct 8, 2024

Is there a fix for this yet?

@kentonv
Copy link
Member

kentonv commented Oct 9, 2024

@edevil where should this be directed?

@edevil
Copy link
Contributor

edevil commented Oct 9, 2024

To me. :) I'll create an internal ticket to track this.

@edevil
Copy link
Contributor

edevil commented Oct 10, 2024

Hey @asimpletune, mind testing it again, please?

@asimpletune
Copy link
Author

Hey @edevil , just tested. message-id works, thanks, but there's a new problem now.

The new issue is headers that are folded now are similarly rejected.

Two problems with this:

1.) it doesn't conform to spec, as folding whitespace is supposed to be disregarded.
2.) anyone who has folded headers now has a broken email worker.

I checked and that's now the case for one of my services.

Here's a link to the rfc5322 spec.

I also have a simple email parser that I wrote. While the code of that project is probably not helpful for this, what may be helpful is the grammar written in EBNF notation.

Probably the simplest way to fix it is just remove any folding whitespace from both emails's headers (the original and the reply) and then do the check.

@edevil
Copy link
Contributor

edevil commented Oct 11, 2024

Hey @asimpletune . Ok fair enough. We are now trimming both the message id header value of the original email, and the in-reply-to header value of the reply email.

This way the values should match whether they are folded, have surrounding whitespace, etc.

@edevil edevil closed this as completed Oct 15, 2024
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

4 participants