waha icon indicating copy to clipboard operation
waha copied to clipboard

[NOWEB][Swagger] Malformatted Error Code

Open AliSot2000 opened this issue 1 year ago • 0 comments

Errors returned from the group functions:

  • POST /api/{session}/groups/{id}/participants/add
  • POST /api/{session}/groups/{id}/participants/remove
  • POST /api/{session}/groups/{id}/admin/promote
  • POST /api/{session}/groups/{id}/admin/demote

Returns on partial error:

[
  {
    "status": "409",
    "jid": "[email protected]",
    "content": {
      "tag": "participant",
      "attrs": {
        "jid": "[email protected]",
        "error": "409"
      }
    }
  }
]

However, other errors the following:

{
  "statusCode": 500,
  "timestamp": "2024-07-07T21:52:05.077Z",
  "exception": {
    "stack": "Error: Timed Out\n    at /app/node_modules/@adiwajshing/baileys/lib/Utils/generics.js:137:32",
    "message": "Timed Out",
    "data": {
      "stack": "Error\n    at promiseTimeout (/app/node_modules/@adiwajshing/baileys/lib/Utils/generics.js:132:19)\n    at waitForMessage (/app/node_modules/@adiwajshing/baileys/lib/Socket/socket.js:120:53)\n    at query (/app/node_modules/@adiwajshing/baileys/lib/Socket/socket.js:142:22)\n    at groupQuery (/app/node_modules/@adiwajshing/baileys/lib/Socket/groups.js:12:55)\n    at Object.groupParticipantsUpdate (/app/node_modules/@adiwajshing/baileys/lib/Socket/groups.js:142:34)\n    at WhatsappSessionNoWebPlus.promoteParticipantsToAdmin (/app/dist/core/engines/noweb/session.noweb.core.js:564:26)\n    at GroupsController.promoteToAdmin (/app/dist/api/groups.controller.js:76:24)\n    at /app/node_modules/@nestjs/core/router/router-execution-context.js:38:29\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"
    },
    "isBoom": true,
    "isServer": false,
    "output": {},
    "name": "Error"
  },
  "request": {
    "path": "/api/default/groups/120363315365001502%40g.us/admin/promote",
    "method": "POST",
    "body": {
      "participants": [
        {
          "id": "1111111111111"
        }
      ]
    },
    "query": {}
  },
  "version": {
    "version": "2024.6.8",
    "engine": "NOWEB",
    "tier": "PLUS",
    "browser": "/usr/bin/chromium"
  }
}

The frustrating part is, that in one part of the code, the returned http status error is a number and somewhere else string. This makes parsing the returned json really hard because the models need to have some smartness to coerce one type to another.

{
  "version": "2024.6.8",
  "engine": "NOWEB",
  "tier": "PLUS",
  "browser": "/usr/bin/chromium"
}

Please Make sure everything is of type number this and / or Document this feature / bug. I would also like to point out that the status of default errors of Express uses numbers. So please align this to the common standard of http and the web and don't do anything funky by using string status codes and especially don't do anything funky if you're not consistent.

This is very much related to This Issue

AliSot2000 avatar Jul 07 '24 21:07 AliSot2000