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

feat(api-service): refactor issue error messages #7359

Merged
merged 24 commits into from
Dec 25, 2024

Conversation

djabarovgeorge
Copy link
Contributor

@djabarovgeorge djabarovgeorge commented Dec 23, 2024

What changed? Why was the change needed?

https://www.loom.com/share/91f0b186dea3470f987ff902ff9b8933

Screenshots

Expand for optional sections

Related enterprise PR

Special notes for your reviewer

Copy link

netlify bot commented Dec 23, 2024

Deploy Preview for dev-web-novu ready!

Name Link
🔨 Latest commit 488e793
🔍 Latest deploy log https://app.netlify.com/sites/dev-web-novu/deploys/676c36548d80300008be3f67
😎 Deploy Preview https://deploy-preview-7359.dashboard.novu-staging.co
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Dec 23, 2024

Deploy Preview for dashboard-v2-novu-staging ready!

Name Link
🔨 Latest commit 488e793
🔍 Latest deploy log https://app.netlify.com/sites/dashboard-v2-novu-staging/deploys/676c36549f07660007782082
😎 Deploy Preview https://deploy-preview-7359.dashboard-v2.novu-staging.co
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

…messages

# Conflicts:
#	apps/api/src/app/workflows-v2/shared/schemas/chat-control.schema.ts
#	apps/api/src/app/workflows-v2/shared/schemas/delay-control.schema.ts
#	apps/api/src/app/workflows-v2/shared/schemas/digest-control.schema.ts
#	apps/api/src/app/workflows-v2/shared/schemas/email-control.schema.ts
#	apps/api/src/app/workflows-v2/shared/schemas/in-app-control.schema.ts
#	apps/api/src/app/workflows-v2/shared/schemas/push-control.schema.ts
#	apps/api/src/app/workflows-v2/shared/schemas/sms-control.schema.ts
@djabarovgeorge djabarovgeorge changed the title feat(api): refactor issue error messages feat(api-service): refactor issue error messages Dec 23, 2024
…messages

# Conflicts:
#	apps/api/src/app/inbox/usecases/get-inbox-preferences/get-inbox-preferences.spec.ts
@djabarovgeorge djabarovgeorge merged commit d327605 into next Dec 25, 2024
42 checks passed
@djabarovgeorge djabarovgeorge deleted the refactor-issue-error-messages branch December 25, 2024 17:37

if (isEmpty(body)) {
return { subject, body: '' };
if (!body || typeof body !== 'string') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit picky comment: Since tip tap processing takes place if the body exists, it is more readable to change the logic to

let renderedBody = '';

  const expandedMailyContent = this.transformMailyDynamicBlocks(body, renderCommand.fullPayloadForRender);
  const parsedTipTap = await this.parseTipTapNodeByLiquid(expandedMailyContent, renderCommand);
  renderedBody = await this.renderEmail(parsedTipTap);
}

return { subject, renderedBody }

): Record<string, unknown> {
const outputSchema = channelStepSchemas[type].output || actionStepSchemas[type].output;

if (!outputSchema || !controlValues) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should throw an error at this point. The inability to identify an outputSchema from the framework indicates an invalid workflow definition.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed, but I tried to handle it as gracefully as possible. maybe we could log and return the controlValues instead? are you sure we need to throw an error here?

Copy link
Contributor

@SokratisVidros SokratisVidros Dec 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Without output schema, there is no step. So we need to fail fast.

@@ -0,0 +1,7 @@
export * from './in-app-control.schema';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These schemas are strictly connected to the built-in Dashboard UI powered by the new Novu workflow V2 API. Do they belong in the application generic? I don't feel strongly about it, but I'd consider it a code smell if these schemas were reused in other services.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting and valid point, i can share why they are in app-gen.
The are in app-gen because i reused the types from the schema in the dashboardSanitizeControlValues function so i needed them close to it, and dashboardSanitizeControlValues is used in Worker.
Let me know what you think about such an implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants