Skip to content

πŸ› Bug Report: @novu/frameworks throws no reasonable error when having invalid configurationΒ #6777

Open
@paulwer

Description

πŸ“œ Description

We had an error, which was releated, to an invalid configuration of our env variables: NOVU_API_URL and NOVU_SECRET_KEY.
We had used the @novu/node lib before and therefore had env in place which met the naming from this lib. (NOVU_BACKEND_URL/NOVU_API_KEY)

This resulted in a misconfiguration (our fault, we could have been reading better :) ) with a strange/wrong debugging experience.
We had to take a deep dive why the following error was present and we were not able to pin down the exact origin for a few hours.

πŸ‘Ÿ Reproduction steps

  1. Deploy self-hosted version
  2. Deploy bridge server without proper env configuration

πŸ‘ Expected behavior

The system tried to reach the cloud url of novu instead of the self-hosted on, which is correct, but the error should represent, that the endpoint could not be reached with this configuration. like a 401 error or similar. The errors in the console of @novu/framework should also be more detailed.

Other suggestions:

  • we would also suggest to use a similar naming across libs for the same thing :)
  • manualy configurable keys, without need to just use the env vars.

πŸ‘Ž Actual Behavior with Screenshots

The error present at the ui was:
Workflow with id: order-recieved has an invalid state. Step with id: in-app has invalid result. Please provide the correct step result.
Unbekannt
The console just shows, that the step could not be hydrated.
image
The ui shows this weird error. We think this is due to the fact, that the step before could not be handled because of the misconfiguration.
Unbekannt

Novu version

Self Hosted

npm version

k.A.

node version

20

πŸ“ƒ Provide any additional context for the Bug.

selfhosted@2.0.0
@novu/framework@2.3.0 also tested on @novu/framework@2.0.0

πŸ‘€ Have you spent some time to check if this bug has been raised before?

  • I checked and didn't find a similar issue

🏒 Have you read the Contributing Guidelines?

Are you willing to submit PR?

None

Our workflow

workflow(
        'order-recieved',
        async ({ step, payload, subscriber }) => {
            await step.inApp('in-app', async () => {
                return {
                    subject: tolgee.t('inApp.orderRecieved.subject', {
                        internal_number: payload.order?.internal_number,
                        language: subscriber?.locale,
                    }),
                    body: tolgee.t('inApp.orderRecieved.body', {
                        internal_number: payload.order?.internal_number,
                        language: subscriber?.locale,
                    }),
                }
            });

            await step.push('send-push', async () => {
                return {
                    subject: tolgee.t('push.orderRecieved.subject', {
                        internal_number: payload.order?.internal_number,
                        language: subscriber?.locale,
                    }),
                    body: tolgee.t('push.orderRecieved.body', {
                        internal_number: payload.order?.internal_number,
                        language: subscriber?.locale,
                    }),
                }
            });

            await step.email('send-email', async () => {
                // TODO: support other order types
                if (payload.order.type !== 'SHOP_PURCHASE_ORDER')
                    throw new Error(`processing of incorrect order type could not be performed. ${payload.order.type}`)

                // the eshop should only support those 3 languages
                const language = ['de', 'en', 'fr'].includes(subscriber?.locale || '') ? subscriber?.locale : 'en';
                await ConfigUtil.init();
                const subject = '...';
                const body = '...';
                return {
                    subject: subject,
                    body: body,
                };
            });
        })

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions