extensions icon indicating copy to clipboard operation
extensions copied to clipboard

🐛 [firestore-send-email] Error "At least one of html, text and template_id should be set" when creating a Firestore doc to trigger the extension

Open rtarnec opened this issue 4 months ago • 4 comments

Describe your configuration

  • Extension name: firestore-send-email
  • Extension version: 0.2.4
  • Sendgrid micro-service provider

Describe the problem

When testing the extension after a successful installation I get an error "Error: Failed to send email. At least one of html, text and template_id should be set"

Steps to reproduce:

Create a document in the collection configured in the Extension (i.e. "emails" in my case) by either using the Firestore console or by using the admin SDK (see below). The document contains a "to" field and a "message" map which contains a "subject" field and a "text" field or an "html" field or both of them.

admin
  .firestore()
  .collection("emails")
  .add({
    to: "[email protected]",
    message: {
      subject: "Hello from Firebase!",
      text: "This is the plaintext section of the email body.",
      html: "This is the <code>HTML</code> section of the email body.",
    },
  })
  .then(() => console.log("Queued email for delivery!"))
  .catch((error) => {
    console.log(error);
  });
Expected result
  • Automatic creation of a "delivery" map field with a "state" field set to SUCCESS and an "error" field set to null
  • Receive the email
  • See the email in the Sendgrid console
Actual result
  • Creation of a "delivery" map field with a "state" field set to ERROR and an "error" field with the following value: "Error: Failed to send email. At least one of html, text and template_id should be set."
  • No email delivered
  • No email in the Sendgrid console
Screenshot of the Firestore console:
Image

rtarnec avatar Aug 14 '25 09:08 rtarnec

This issue does not seem to follow the issue template. Make sure you provide all the required information.

google-oss-bot avatar Aug 14 '25 09:08 google-oss-bot

Hi @rtarnec

Thanks for reporting this issue! We’ve received it and are reviewing it. We’ll provide updates as soon as possible.

CorieW avatar Aug 19 '25 14:08 CorieW

I haven't been able to reproduce this issue via the Firebase Console.

Have you been able to produce this directly though the Firebase Console?

Can you provide your extension configuration, please?

CorieW avatar Aug 19 '25 16:08 CorieW

Hi @CorieW,

Thank you for your help.

I confirm that I was able to produce this directly through the Firebase Console as well as using the Admin SDK.

Here is the config:

Firestore Instance ID (default)

Firestore Instance Location australia-southeast2

Authentication Type UsernamePassword

SMTP connection URI (Optional) smtps://apikey:[email protected]:465

SMTP password (Optional) Parameter not set

OAuth2 SMTP Host (Optional) Parameter not set

OAuth2 SMTP Port (Optional) 465

Use secure OAuth2 connection? (Optional) true

OAuth2 Client ID (Optional) Parameter not set

OAuth2 Client Secret (Optional) Parameter not set

OAuth2 Refresh Token (Optional) Parameter not set

OAuth2 SMTP User (Optional) Parameter not set

Email documents collection emails

Default FROM address [email protected]

Default REPLY-TO address (Optional) Parameter not set

Users collection (Optional) Parameter not set

Templates collection (Optional) Parameter not set

Firestore TTL type never

Firestore TTL value 1 TLS Options (Optional) Parameter not set

Note that since configuring the extension, I’ve realized that adding the SendGrid API key directly in the SMTP connection URI doesn’t seem to be the correct approach anymore (see: https://stackoverflow.com/a/71431728/3371862 ). However, I haven’t yet tried updating the configuration according to that Stack Overflow response.

rtarnec avatar Aug 19 '25 16:08 rtarnec