P
Prisma•2mo ago
Ortharion

Bad error messages with array of transactions

I'm concatenating my transactions like this

if (!isNil(changes.systems))
transactions = transactions.concat(this.handleSystemChanges(changes.systems, lastPulledAt));
if (!isNil(changes.equipment_photos))
transactions = transactions.concat(this.handleEquipmentPhotoChanges(changes.equipment_photos, lastPulledAt));

if (!isNil(changes.systems))
transactions = transactions.concat(this.handleSystemChanges(changes.systems, lastPulledAt));
if (!isNil(changes.equipment_photos))
transactions = transactions.concat(this.handleEquipmentPhotoChanges(changes.equipment_photos, lastPulledAt));
My payload looks like this
{
"equipment_photos" : {
"created": [
{
"id": "123",
"unknownProperty": "test"
}
],
"updated" : [],
"deleted" : ["0e306bfd-19d4-4a5d-a236-8b6b0b6eb5e6"]
},
"systems": {
"created": [],
"updated" : [],
"deleted" : ["0e306bfd-19d4-4a5d-a236-8b6b0b6eb5e6"]
}

}
{
"equipment_photos" : {
"created": [
{
"id": "123",
"unknownProperty": "test"
}
],
"updated" : [],
"deleted" : ["0e306bfd-19d4-4a5d-a236-8b6b0b6eb5e6"]
},
"systems": {
"created": [],
"updated" : [],
"deleted" : ["0e306bfd-19d4-4a5d-a236-8b6b0b6eb5e6"]
}

}
But my error looks like this (it will be the first comment...my post was too long apparently) The import part is that last line there "unknown argument 'unknownProperty'" Great! ... "prisma.systems.upsert" wait what. No. That error is actually on prisma.equipmentPhotos.upsert Prisma appears to be taking the first element in the array of transactions and attributing the error to that when the actual error is somewhere else. Is this a bug with prisma or should I be handling my transaction differently?
5 Replies
Ortharion
Ortharion•2mo ago
Actual prisma error
"message": "\nInvalid `prisma.systems.upsert()` invocation:\n\n{\n where: {\n id: \"0e306bfd-19d4-4a5d-a236-8b6b0b6eb5e6\"\n },\n create: {\n id: \"7de075b7-179f-4762-a615-619e10b6214a\",\n updated_by: \"b9ad90e0-17fc-4e22-b715-a62073f6b42a\",\n updated_at: 1726098171191,\n deleted_at: 1726098171191,\n? parent?: String | Null,\n? regularImageName?: String | Null,\n? infraredImageName?: String | Null,\n? description?: String | Null,\n? system?: String | Null,\n? uploaded?: Boolean | Null,\n? simulation?: String | Null,\n? category?: String | Null,\n? originalEquipmentId?: String | Null,\n? latitude?: Int | Null,\n? longitude?: Int | Null,\n? altitude?: Int | Null,\n? heading?: Int | Null,\n? locationAccuracy?: Int | Null,\n? altitudeAccuracy?: Int | Null,\n? detectedInfo?: NullableJsonNullValueInput | Json,\n? created_at?: BigInt | Null,\n? created_by?: String | Null\n },\n update: {\n updated_by: \"b9ad90e0-17fc-4e22-b715-a62073f6b42a\",\n updated_at: 1726098171191,\n deleted_at: 1726098171191\n }\n}\n\nUnknown argument `unknownProperty`. Available options are marked with ?."
"message": "\nInvalid `prisma.systems.upsert()` invocation:\n\n{\n where: {\n id: \"0e306bfd-19d4-4a5d-a236-8b6b0b6eb5e6\"\n },\n create: {\n id: \"7de075b7-179f-4762-a615-619e10b6214a\",\n updated_by: \"b9ad90e0-17fc-4e22-b715-a62073f6b42a\",\n updated_at: 1726098171191,\n deleted_at: 1726098171191,\n? parent?: String | Null,\n? regularImageName?: String | Null,\n? infraredImageName?: String | Null,\n? description?: String | Null,\n? system?: String | Null,\n? uploaded?: Boolean | Null,\n? simulation?: String | Null,\n? category?: String | Null,\n? originalEquipmentId?: String | Null,\n? latitude?: Int | Null,\n? longitude?: Int | Null,\n? altitude?: Int | Null,\n? heading?: Int | Null,\n? locationAccuracy?: Int | Null,\n? altitudeAccuracy?: Int | Null,\n? detectedInfo?: NullableJsonNullValueInput | Json,\n? created_at?: BigInt | Null,\n? created_by?: String | Null\n },\n update: {\n updated_by: \"b9ad90e0-17fc-4e22-b715-a62073f6b42a\",\n updated_at: 1726098171191,\n deleted_at: 1726098171191\n }\n}\n\nUnknown argument `unknownProperty`. Available options are marked with ?."
RaphaelEtim
RaphaelEtim•2mo ago
Hi @Ortharion 👋 Can you please share your schema and is it possible to use this approach for your your transaction to see if the error persist?
Transactions and batch queries (Reference) | Prisma Documentation
This page explains the transactions API of Prisma Client.
Ortharion
Ortharion•2mo ago
Apologies, I thought I was doing that approach? Oh I didn't put the actual line of the transaction.
//this is what the concatenated transactions would look like after all the //condition checks from the original code snippet. This is just for brevity.
//This code works in production and this is just to isolate the example of an //error state not bubbling up properly
const transactions = [
this.prismaClient.systems.upsert(query),
this.prismaClient.equipmentPhotos.upsert(query)
]


const result = await this.prismaClient.$transaction(transactions);
//this is what the concatenated transactions would look like after all the //condition checks from the original code snippet. This is just for brevity.
//This code works in production and this is just to isolate the example of an //error state not bubbling up properly
const transactions = [
this.prismaClient.systems.upsert(query),
this.prismaClient.equipmentPhotos.upsert(query)
]


const result = await this.prismaClient.$transaction(transactions);
And the schema isn't super important here. I intentionally put a bad property to force the error. Getting an error isn't the issue, it's when we have errors, prisma is NOT bubbling the correct information. I'm pretty sure this is a bug report and not a request for help. But I wanted to make sure I didn't miss something in the docs somewhere about how to properly manage errors when using an array of prisma promises in a $transaction
RaphaelEtim
RaphaelEtim•2mo ago
Can you please fill out this bug template so our engineering team can take a look?
Ortharion
Ortharion•2mo ago
Sure. Thanks
Want results from more Discord servers?
Add your server