Is this an invalid action? Getting a 500 when calling, no error logs

I'm trying to do a simple update call but getting a 500 from prisma, with this message
Error:
Invalid `prisma.creators.update()` invocation:

{
+ data: CreatorsUpdateInput | CreatorsUncheckedUpdateInput,
+ where: {
+ id?: Int,
+ userId?: Int
+ }
}

Argument data is missing.
Argument where is missing.

Note: Lines with + are required
Error:
Invalid `prisma.creators.update()` invocation:

{
+ data: CreatorsUpdateInput | CreatorsUncheckedUpdateInput,
+ where: {
+ id?: Int,
+ userId?: Int
+ }
}

Argument data is missing.
Argument where is missing.

Note: Lines with + are required
This is my action:
export const modifyVerificationStatusCreator = async ({ verify, idToUpdate, userIdToUpdate }, context) => {
if (!verify || !idToUpdate) {
throw new Error('Both `verify` and `idToUpdate` are required.');
}
console.log(verify, idToUpdate);
if (!context.user) {
throw new HttpError(401);
}
return await context.entities.Creators.update({
where: {
id: idToUpdate,
userId: userIdToUpdate,
},
data: {
verified: verify,
},
});
};
export const modifyVerificationStatusCreator = async ({ verify, idToUpdate, userIdToUpdate }, context) => {
if (!verify || !idToUpdate) {
throw new Error('Both `verify` and `idToUpdate` are required.');
}
console.log(verify, idToUpdate);
if (!context.user) {
throw new HttpError(401);
}
return await context.entities.Creators.update({
where: {
id: idToUpdate,
userId: userIdToUpdate,
},
data: {
verified: verify,
},
});
};
4 Replies
kapa.ai
kapa.ai2w ago
Hi @CamBlackwood. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- Based on the provided knowledge sources and your action code, it appears that the action itself is not invalid. However, there might be an issue with how the action is being called or how the arguments are being passed. Let's analyze the potential problems: 1. Error Handling: The error message you're seeing is actually coming from Prisma, not Wasp directly. This suggests that the action is reaching the Prisma client, but the client is rejecting the operation. 2. Argument Passing: The error message indicates that the data and where arguments are missing. This is strange because your action code clearly includes both of these. This could suggest that the values for idToUpdate and userIdToUpdate might be undefined when the action is called. 3. Type Checking: If you're using TypeScript, make sure that the types for idToUpdate and userIdToUpdate match what Prisma expects (likely number for an Int field). 4. Error Propagation: Wasp typically wraps Prisma errors to avoid leaking sensitive information. The fact that you're seeing the raw Prisma error suggests that this error handling might not be working as expected in your case. To help debug this issue, you could try the following: 1. Add more logging in your action, especially to check the values of idToUpdate and userIdToUpdate:
console.log('idToUpdate:', idToUpdate, 'type:', typeof idToUpdate);
console.log('userIdToUpdate:', userIdToUpdate, 'type:', typeof userIdToUpdate);
console.log('idToUpdate:', idToUpdate, 'type:', typeof idToUpdate);
console.log('userIdToUpdate:', userIdToUpdate, 'type:', typeof userIdToUpdate);
2. Wrap the Prisma call in a try-catch block to see if there are any additional details:
try {
return await context.entities.Creators.update({
where: {
id: idToUpdate,
userId: userIdToUpdate,
},
data: {
verified: verify,
},
});
} catch (error) {
console.error('Prisma error:', error);
throw new HttpError(500, 'Database operation failed', { originalError: error });
}
try {
return await context.entities.Creators.update({
where: {
id: idToUpdate,
userId: userIdToUpdate,
},
data: {
verified: verify,
},
});
} catch (error) {
console.error('Prisma error:', error);
throw new HttpError(500, 'Database operation failed', { originalError: error });
}
3. Check how you're calling this action from the client side. Make sure you're passing all required arguments correctly. 4. Verify that your Prisma schema matches the structure you're using in the action. If the problem persists, you might want to check your server logs for more detailed error information. The Wasp documentation on error handling suggests that you can throw an HttpError with additional information to get more details on the client side. Remember, 500 errors often indicate server-side issues, so focusing on server-side debugging (like adding more logs) is likely to be most helpful in resolving this issue. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @CamBlackwood, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist: Perhaps try again in 15mins?
CamBlackwood
CamBlackwoodOP2w ago
I've solved it - for future reference, I misunderstood an error message so was trying to identify by two different where arguments. I'm not sure what caused the original issue, but it's sorted now
matijash
matijash2w ago
hah interesting! what did you do to fix it?
CamBlackwood
CamBlackwoodOP2w ago
@matijash for the original bug - I'm not 100% sure to be honest. It may have been a ts compilation issue - once I removed the conflicting where statement it started working

Did you find this page helpful?