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

Multiples retries in courier using SendGrid with mail API #3399

Closed
4 of 6 tasks
a-damian opened this issue Jul 26, 2023 · 0 comments · Fixed by #3401
Closed
4 of 6 tasks

Multiples retries in courier using SendGrid with mail API #3399

a-damian opened this issue Jul 26, 2023 · 0 comments · Fixed by #3401
Assignees
Labels
bug Something is not working.

Comments

@a-damian
Copy link

Preflight checklist

Describe the bug

Using courier with delivery_strategy: http on kratos v.1.0.0 and configs for SendGrid API, kratos is sending the email and SendGrid response has a status code of 202, causing to trigger the message_retries, so for example if I send a verification email with a message_retries: 5, it ends sending me 6 emails in total.
SendGrid returns a 202 in success cases on their API https://docs.sendgrid.com/api-reference/mail-send/mail-send

Reproducing the bug

Setup kratos v1.0.0 with settings in courier to use delivery_strategy: http and configure for SendGrid API, then send an email in a flow like verification flow, then Kratos will send multiple emails depending of how many retries are configured. Ej.message_retries: 5

Relevant log output

{"audience":"application","file":"/go/pkg/mod/github.com/ory/x@v0.0.562/logrusx/helper.go:125","func":"github.com/ory/x/logrusx.(*Logger).Logf","level":"info","msg":"[DEBUG] POST https://api.sendgrid.com/v3/mail/send","service_name":"Ory Kratos","service_version":"v1.0.0","time":"2023-07-26T22:56:11.2612334Z"}

{"audience":"application","error":{"message":"unable to dispatch mail delivery because upstream server replied with status code 202","stack_trace":"stack trace could not be recovered from error type *errors.errorString"},"file":"/project/courier/http.go:81","func":"github.com/ory/kratos/courier.(*courier).dispatchMailerEmail","level":"error","message_id":"fcaff15e-709e-49a4-a712-0f10082efd0f","message_subject":"Test Subject","message_template_type":"verification_code_valid","message_type":"email","msg":"sending mail via HTTP failed.","service_name":"Ory Kratos","service_version":"v1.0.0","time":"2023-07-26T22:56:11.866128Z"}

{"audience":"application","file":"/go/pkg/mod/github.com/ory/x@v0.0.562/logrusx/helper.go:125","func":"github.com/ory/x/logrusx.(*Logger).Logf","level":"info","msg":"[DEBUG] POST https://api.sendgrid.com/v3/mail/send","service_name":"Ory Kratos","service_version":"v1.0.0","time":"2023-07-26T22:56:12.6117559Z"}

{"audience":"application","error":{"message":"unable to dispatch mail delivery because upstream server replied with status code 202","stack_trace":"stack trace could not be recovered from error type *errors.errorString"},"file":"/project/courier/http.go:81","func":"github.com/ory/kratos/courier.(*courier).dispatchMailerEmail","level":"error","message_id":"fcaff15e-709e-49a4-a712-0f10082efd0f","message_subject":"Test subject","message_template_type":"verification_code_valid","message_type":"email","msg":"sending mail via HTTP failed.","service_name":"Ory Kratos","service_version":"v1.0.0","time":"2023-07-26T22:56:12.701756Z"}

{"audience":"application","file":"/go/pkg/mod/github.com/ory/x@v0.0.562/logrusx/helper.go:125","func":"github.com/ory/x/logrusx.(*Logger).Logf","level":"warning","message_id":"fcaff15e-709e-49a4-a712-0f10082efd0f","message_nid":"e6bf53a3-9805-4617-9ccf-2be4787cc10e","msg":"Message was abandoned because it did not deliver after 2 attempts","service_name":"Ory Kratos","service_version":"v1.0.0","time":"2023-07-26T22:56:13.4521965Z"}

Relevant configuration

courier:
  message_retries: 1
  delivery_strategy: http
  http:
    request_config:
      url: https://api.sendgrid.com/v3/mail/send
      method: POST
      body: base64://SENDGRID_JSONNET_BODY_MAP
      headers:
        'Content-Type': 'application/json'
      auth:
        type: api_key
        config:
          name: Authorization
          value: Bearer SENDGRID_API_KEY
          in: header

Version

v1.0.0

On which operating system are you observing this issue?

Windows

In which environment are you deploying?

Kubernetes with Helm

Additional Context

No response

@a-damian a-damian added the bug Something is not working. label Jul 26, 2023
@aeneasr aeneasr self-assigned this Jul 28, 2023
aeneasr added a commit that referenced this issue Jul 28, 2023
hperl pushed a commit that referenced this issue Aug 1, 2023
hperl pushed a commit that referenced this issue Aug 1, 2023
* fix: accept all 200 responses as OK in courier

Closes #3399

* chore: synchronize workspaces
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants