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

Failed to send notification, Error Code: undefined #64

Open
vsmart-duo opened this issue Nov 7, 2023 · 4 comments
Open

Failed to send notification, Error Code: undefined #64

vsmart-duo opened this issue Nov 7, 2023 · 4 comments
Labels
documentation Improvements or additions to documentation question Further information is requested

Comments

@vsmart-duo
Copy link

Hey @Tethik and team! Very exciting that Gram is open source now 🙌

I tried following the Getting Started guide. The app started successfully but then I got stuck at the Login screen. When trying the "login via magic link" button, I got this error. I tried with 2 different email addresses:

[2023-11-07T14:28:04.172] [ERROR] NotificationSender - Failed to send notification 1: SMTP Error Code: undefined. See https://github.com/eleith/emailjs/blob/main/smtp/error.ts

  • Is this supposed to work locally / in Dev mode? (on MacOS)
  • If not, what's the alternative for logging in locally?

Full error log here, emails and tokens redacted:

[2023-11-07T14:27:34.163] [DEBUG] NotificationSender - No new notifications to send
[2023-11-07T14:27:54.570] [DEBUG] MagicLinkIdentityProvider - Sending magic link to <REDACTED> with link http://localhost:4726/login/callback/magic-link?token=<REDACTED>
[2023-11-07T14:27:54.611] [DEBUG] NotificationDataService - Queued new mail magic-link - {"templateKey":"magic-link","params":{"link":"http://localhost:4726/login/callback/magic-link?token=<REDACTED>","recipient":{"sub":"<REDACTED>","to":"<REDACTED>}}}
[2023-11-07T14:27:54.613] [INFO] auditHttp - POST /api/v1/auth/token?provider=magic-link 44ms
[2023-11-07T14:27:54.613] [DEBUG] auditHttp - body {"email":"<REDACTED>"}
[2023-11-07T14:27:54.634] [INFO] auditHttp - GET /api/v1/user 0ms
[2023-11-07T14:28:04.138] [DEBUG] wss - Number active channels: 0
[2023-11-07T14:28:04.172] [ERROR] NotificationSender - Failed to send notification 1: SMTP Error Code: undefined. See https://github.com/eleith/emailjs/blob/main/smtp/error.ts
[2023-11-07T14:28:04.172] [WARN] NotificationSender - Failed to send notifications [1]
[2023-11-07T14:28:34.138] [DEBUG] wss - Number active channels: 0
[2023-11-07T14:28:34.178] [DEBUG] NotificationSender - No new notifications to send
[2023-11-07T14:29:04.139] [DEBUG] wss - Number active channels: 0
[2023-11-07T14:29:04.178] [DEBUG] NotificationSender - No new notifications to send
[2023-11-07T14:29:12.229] [DEBUG] MagicLinkIdentityProvider - Sending magic link to <REDACTED> with link http://localhost:4726/login/callback/magic-link?token=<REDACTED>
[2023-11-07T14:29:12.267] [DEBUG] NotificationDataService - Queued new mail magic-link - {"templateKey":"magic-link","params":{"link":"http://localhost:4726/login/callback/magic-link?token=<REDACTED>","recipient":{"sub":"<REDACTED>","to":"<REDACTED>"}}}
[2023-11-07T14:29:12.268] [INFO] auditHttp - POST /api/v1/auth/token?provider=magic-link 39ms
[2023-11-07T14:29:12.268] [DEBUG] auditHttp - body {"email":"<REDACTED>"}
[2023-11-07T14:29:12.292] [INFO] auditHttp - GET /api/v1/user 3ms
[2023-11-07T14:29:34.140] [DEBUG] wss - Number active channels: 0
[2023-11-07T14:29:34.183] [ERROR] NotificationSender - Failed to send notification 2: SMTP Error Code: undefined. See https://github.com/eleith/emailjs/blob/main/smtp/error.ts
[2023-11-07T14:29:34.183] [WARN] NotificationSender - Failed to send notifications [2]
[2023-11-07T14:30:04.141] [DEBUG] wss - Number active channels: 0
@Tethik
Copy link
Member

Tethik commented Nov 7, 2023

Hej @vsmart-duo - super excited to see you try it out :)

The error you see is likely due to SMTP not being able to send anything (I'm assuming here that it has no configuration at all).

The magic link is logged beforehand via debug, try clicking the link that's logged here:

[2023-11-07T14:29:12.229] [DEBUG] MagicLinkIdentityProvider - Sending magic link to <REDACTED> with link http://localhost:4726/login/callback/magic-link?token=<REDACTED>

@Tethik Tethik added question Further information is requested documentation Improvements or additions to documentation labels Nov 7, 2023
@Tethik
Copy link
Member

Tethik commented Nov 7, 2023

If using just the default configuration, you will also need to use one of the predefined user emails here:
https://github.com/klarna-incubator/gram/blob/main/config/default.ts#L103-L119

    const sampleUsers: User[] = [
      {
        name: "User",
        sub: "user@localhost", // Must be the same as sub provided by IdentityProvider for authz to work
        mail: "user@localhost",
      },
      {
        name: "Reviewer",
        sub: "reviewer@localhost",
        mail: "reviewer@localhost",
      },
      {
        name: "Admin",
        sub: "admin@localhost",
        mail: "admin@localhost",
      },
    ];

Otherwise I believe the app will not permit you in due to authz issues - the app will attempt a user lookup on the email address, then fail if it doesn't find it.

✅ Updated the QuickStart quickly to reflect this

@vsmart-duo
Copy link
Author

yes, that worked! 🎉
First I tried clicking the link directly but as you expected it failed with "User not found"
Then following the instructions in the second comment I was able to login with user@localhost 👍

@Tethik
Copy link
Member

Tethik commented Nov 7, 2023

Cool, let me know if you find any further issues. I think you're the first to actually try this out - so I appreciate the testing 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants