π Bug Report: @novu/frameworks throws no reasonable error when having invalid configurationΒ #6777
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
- Deploy self-hosted version
- 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.
The console just shows, that the step could not be hydrated.
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.
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?
- I have 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,
};
});
})