Bug Description
POST /chat/archiveChat/{instanceName} always returns HTTP 500 with a PrismaClientValidationError.
Environment
- Evolution API version: 2.3.7
- Integration: WHATSAPP-BAILEYS
- Database: PostgreSQL 15
Steps to Reproduce
- Connect a WhatsApp instance via Baileys
- Send a message to a contact (so a chat exists)
- Call
POST /chat/archiveChat/{instanceName} with:
{
"lastMessages": \[{
"key": {
"id": "3EB09C555B385CF03875A8",
"fromMe": true,
"remoteJid": "5519999999999@s.whatsapp.net"
},
"messageTimestamp": 1775243556
}],
"archive": true
}
- Also tried:
PUT method (returns 404), simplified payload {"chat":"...","archive":true}, and with/without lastMessages
Error Response
{
"status": 500,
"error": "Internal Server Error",
"response": {
"message": \[{
"archived": false,
"message": \[
"An error occurred while archiving the chat. Open a calling.",
"PrismaClientValidationError: Invalid `this.prismaRepository.contact.findMany()` invocation\\n\\nUnknown argument `remoteJid`. Available options are marked with ?"
]
}]
}
}
Root Cause Analysis
The archiveChat method calls G(o) (the JID normalizer), which internally calls whatsappNumber(). This function executes:
this.prismaRepository.contact.findMany({
where: {
instanceId: this.instanceId,
remoteJid: { in: users.map(({ jid }) => jid) }
}
})
The Contact Prisma model does not expose remoteJid as a direct filterable field in the where clause at line 275 of the compiled main.js. The error Unknown argument "remoteJid" confirms a schema mismatch.
Suggested Fix
In whatsapp.baileys.service.ts, the whatsappNumber method query should match the current Prisma schema for the Contact model. Either:
- Ensure
remoteJid is a direct scalar field on the Contact model (not nested in JSON)
- Or update the query to use the correct field path if the schema changed
The archiveChat function itself is correct — it properly calls this.client.chatModify(). The bug is in the JID resolution path (G() → whatsappNumber() → contact.findMany()).
Impact
archiveChat is completely broken on v2.3.7
markChatUnread may also be affected (same code path)
- Any function routing through
whatsappNumber() could hit this
Workaround
Archive only at the application level. The Baileys chatModify call is never reached.
Bug Description
POST /chat/archiveChat/{instanceName}always returns HTTP 500 with aPrismaClientValidationError.Environment
Steps to Reproduce
POST /chat/archiveChat/{instanceName}with:{ "lastMessages": \[{ "key": { "id": "3EB09C555B385CF03875A8", "fromMe": true, "remoteJid": "5519999999999@s.whatsapp.net" }, "messageTimestamp": 1775243556 }], "archive": true }PUTmethod (returns 404), simplified payload{"chat":"...","archive":true}, and with/withoutlastMessagesError Response
{ "status": 500, "error": "Internal Server Error", "response": { "message": \[{ "archived": false, "message": \[ "An error occurred while archiving the chat. Open a calling.", "PrismaClientValidationError: Invalid `this.prismaRepository.contact.findMany()` invocation\\n\\nUnknown argument `remoteJid`. Available options are marked with ?" ] }] } }Root Cause Analysis
The
archiveChatmethod callsG(o)(the JID normalizer), which internally callswhatsappNumber(). This function executes:The
ContactPrisma model does not exposeremoteJidas a direct filterable field in thewhereclause at line 275 of the compiledmain.js. The errorUnknown argument "remoteJid"confirms a schema mismatch.Suggested Fix
In
whatsapp.baileys.service.ts, thewhatsappNumbermethod query should match the current Prisma schema for theContactmodel. Either:remoteJidis a direct scalar field on theContactmodel (not nested in JSON)The
archiveChatfunction itself is correct — it properly callsthis.client.chatModify(). The bug is in the JID resolution path (G()→whatsappNumber()→contact.findMany()).Impact
archiveChatis completely broken on v2.3.7markChatUnreadmay also be affected (same code path)whatsappNumber()could hit thisWorkaround
Archive only at the application level. The Baileys
chatModifycall is never reached.