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

JSONDecodeError on 503 responses #111

Open
itssimon opened this issue Jun 11, 2024 · 2 comments
Open

JSONDecodeError on 503 responses #111

itssimon opened this issue Jun 11, 2024 · 2 comments

Comments

@itssimon
Copy link

I've been getting a few 503 responses from the Resend API when calling resend.Emails.send() recently, with the response body being HTML. This library tries to parse that as JSON and raises a JSONDecodeError. Would be nice if that could be handled more gracefully.

The response body that causes this error looks like this:

<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta charset="utf-8" />
    <title>Server Error</title>
    ...
@drish
Copy link
Collaborator

drish commented Jun 12, 2024

thanks for reporting @itssimon, sure thing, ill double check that.

@gustavjohansen98
Copy link

gustavjohansen98 commented Jun 20, 2024

@drish any updates ?

I'm facing the same issue, and the error info doesn't really help:

Expecting value: line 1 column 1 (char 0)

It's quite critical for our business to be able to send order confirmations, and so far we've been comfortably relying on Resend for that - please help ASAP :))


I pass html as an f string to the html entry of the sendParams, like this:

send_params = {
	'from': 'Company <mail@company.com>',
	'to': ['mail@user.com'],
	'subject': f'Your order is confirmed #{order_number}',
	'html': generate_order_confirmation_html(...),
}

def generate_order_confirmation_html(arg):
	return f'''
	<center style="width: 100%; table-layout: fixed; background-color: #F5F0E6; padding: 20px 0 100px">
		<p>{arg}</p>
	</center>
	'''

Args are always of type str and sometimes I embed a base64 encoded QR code in an img element, however, the JSONDecodeError occurs with and without any base64 embeddings.


Resend version 2.1.0

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

3 participants