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

🐛 Bug Report: cta.action empty string in messagetemplates mongo collection #4987

Closed
2 tasks done
daolfer opened this issue Dec 15, 2023 · 2 comments
Closed
2 tasks done

Comments

@daolfer
Copy link

daolfer commented Dec 15, 2023

📜 Description

We are finding some scenarios where cta.action is an empty string in messagetemplates mongo collection. This causes an Cannot create property 'buttons' on string '' error when trying to call to subscribers/[subscriberId]/notifications/feed endpoint

👟 Reproduction steps

  1. From novu web go to workflows section and define a new workflow with an in-Appstep
  2. In this step you can add a message and you can create no actions associated to that message
    image
    In database the collection created is something similar to this
{
  "type": "in_app",
  "active": true,
  "subject": "",
  "variables": [ ... ],
  "content": "...",
  "contentType": "editor",
  "cta": {
    "data": {
      "url": "..."
    },
    "type": "redirect",
    "action": ""
  },
  "_environmentId": {
    "$oid": "63e4ab490bed44e5c6c51420"
  },
  "_organizationId": {
    "$oid": "63e4ab490bed44e5c6c5141a"
  },
  "_creatorId": {
    "$oid": "64c8e62b80cc8ccb5ad8abcd"
  },
  "_feedId": {
    "$oid": "648057a4496ae26089bd4020"
  },
  "_layoutId": null,
  "createdAt": {
    "$date": "2023-08-07T10:35:34.605Z"
  },
  "updatedAt": {
    "$date": "2023-12-15T09:04:15.135Z"
  },
  "__v": 0,
  "actor": {
    "type": "none",
    "data": null
  }
}

where cta.actionis an empty string.

👍 Expected behavior

It should create cta.action as an empty object not as an empty string, so calling to subscribers/[subscriberId]/notifications/feed endpoint may not return an error.

👎 Actual Behavior with Screenshots

Worker service, when tries to process the messages is creating a new message in mongo with the field cta.actionas an empty string.
When trying to call to subscribers/[subscriberId]/notifications/feed endpoint we are getting the following error

{
  "insertId": "06y8xcljy31zqmj9",
  "jsonPayload": {
    "organizationId": "63eb559766b0e27ff9604f4d",
    "msg": "Cannot create property 'buttons' on string ''",
    "req": {
      "query": {
        "feedIdentifier": "Alert",
        "seen": "false"
      },
      "params": {
        "0": "subscribers/63b0959d-2ab0-4ac0-b993-8c98095f9ece/notifications/feed"
      },
      "remoteAddress": "....",
      "url": "/v1/subscribers/63b0959d-2ab0-4ac0-b993-8c98095f9ece/notifications/feed?feedIdentifier=Alert&seen=false",
      "id": 7474022,
      "headers": {},
      "method": "GET",
      "remotePort": 58638
    },
    "environmentId": "63eb559766b0e27ff9604f6f",
    "serviceName": "@novu/api",
    "platform": "Docker",
    "serviceVersion": "0.19.0",
    "err": {
      "message": "Cannot create property 'buttons' on string ''",
      "type": "Error",
      "stack": "TypeError: Cannot create property 'buttons' on string ''\n    at applyDefaults (/usr/src/app/node_modules/.pnpm/[email protected]/node_modules/mongoose/lib/helpers/document/applyDefaults.js:106:25)\n    at model.Document.$__init (/usr/src/app/node_modules/.pnpm/[email protected]/node_modules/mongoose/lib/document.js:705:3)\n    at model.syncWrapper [as $__init] (/usr/src/app/node_modules/.pnpm/[email protected]/node_modules/kareem/index.js:331:25)\n    at model.Document.init (/usr/src/app/node_modules/.pnpm/[email protected]/node_modules/mongoose/lib/document.js:638:8)\n    at model.Document.$init (/usr/src/app/node_modules/.pnpm/[email protected]/node_modules/mongoose/lib/document.js:654:42)\n    at completeMany (/usr/src/app/node_modules/.pnpm/[email protected]/node_modules/mongoose/lib/helpers/query/completeMany.js:43:14)\n    at cb (/usr/src/app/node_modules/.pnpm/[email protected]/node_modules/mongoose/lib/query.js:2316:5)\n    at /usr/src/app/node_modules/.pnpm/[email protected]/node_modules/mongodb/src/utils.ts:461:15\n    at runMicrotasks (<anonymous>)\n    at processTicksAndRejections (node:internal/process/task_queues:96:5)"
    },
    "pid": 17,
    "userId": "63eb558466b0e27ff9604f2e",
    "level": 50,
    "context": "ExceptionsHandler",
    "tenant": "OS"
  },
  "timestamp": "2023-12-15T05:01:42.807Z",
  "receiveTimestamp": "2023-12-15T05:01:47.735874145Z"
}

Novu version

0.19.0

npm version

No response

node version

No response

📃 Provide any additional context for the Bug.

No response

👀 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

@jainpawan21
Copy link
Member

jainpawan21 commented Dec 16, 2023

@daolfer

I see you are self-hosting Novu and your Novu version is 0.19.0
I tried to reproduce this issue on Novu managed saas web.novu.co which is running on the latest version 0.22.0. I could not reproduce this issue
https://www.loom.com/share/b0f697aba2684deda7d5280d8af1561b

Could you please upgrade the Novu version to latest?

@jainpawan21
Copy link
Member

Closing this issue as it is not reproducible

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

No branches or pull requests

2 participants