twendy1
twendy12w ago

Help with RevenueCat webhook

Hello, I was trying to setup Convex with RevenueCat webhook. Mostly the logic works fine but it breaks after I fetched subscriber information from RevenueCat and tried to parse json from response. It seems like RevenueCat includes field with key $attConsentStatus and Convex doesnt like it because we are getting validator error:
Uncaught Error: Field name $attConsentStatus starts with a '$', which is reserved.
at validateObjectField (../../node_modules/convex/src/values/value.ts:162:2)
at convexToJsonInternal (../../node_modules/convex/src/values/value.ts:349:6)
at convexToJsonInternal (../../node_modules/convex/src/values/value.ts:350:15)
at convexToJsonInternal (../../node_modules/convex/src/values/value.ts:350:15)
at convexToJson (../../node_modules/convex/src/values/value.ts:417:0)
at syscallArgs (../../node_modules/convex/src/server/impl/actions_impl.ts:16:4)
at runMutation [as runMutation] (../../node_modules/convex/src/server/impl/actions_impl.ts:40:6)
at handler (../convex/revenuecatActions.ts:87:16)
Uncaught Error: Field name $attConsentStatus starts with a '$', which is reserved.
at validateObjectField (../../node_modules/convex/src/values/value.ts:162:2)
at convexToJsonInternal (../../node_modules/convex/src/values/value.ts:349:6)
at convexToJsonInternal (../../node_modules/convex/src/values/value.ts:350:15)
at convexToJsonInternal (../../node_modules/convex/src/values/value.ts:350:15)
at convexToJson (../../node_modules/convex/src/values/value.ts:417:0)
at syscallArgs (../../node_modules/convex/src/server/impl/actions_impl.ts:16:4)
at runMutation [as runMutation] (../../node_modules/convex/src/server/impl/actions_impl.ts:40:6)
at handler (../convex/revenuecatActions.ts:87:16)
Here is the code which Im using for fetching data (which is in Try/Catch), written inside internalAction:
const response = await fetch(url, {
method: 'GET',
headers: {
Authorization: `Bearer ${apiKey}`,
Accept: 'application/json',
'Content-Type': 'application/json',
},
});

const customerInfo = (await response.json()) as RevenueCatCustomerInfoResponse;
const response = await fetch(url, {
method: 'GET',
headers: {
Authorization: `Bearer ${apiKey}`,
Accept: 'application/json',
'Content-Type': 'application/json',
},
});

const customerInfo = (await response.json()) as RevenueCatCustomerInfoResponse;
4 Replies
Convex Bot
Convex Bot2w ago
Thanks for posting in <#1088161997662724167>. Reminder: If you have a Convex Pro account, use the Convex Dashboard to file support tickets. - Provide context: What are you trying to achieve, what is the end-user interaction, what are you seeing? (full error message, command output, etc.) - Use search.convex.dev to search Docs, Stack, and Discord all at once. - Additionally, you can post your questions in the Convex Community's <#1228095053885476985> channel to receive a response from AI. - Avoid tagging staff unless specifically instructed. Thank you!
dejeszio
dejeszio2w ago
What code is giving the error, can you debug and see what causes that error to be thrown, cause the code you gave - I don’t see why that would give an error as it doesn’t do anything except get the response from revenuecat. If the validator is being triggered it would mean that you are passing it to the validator, so are you passing this data to a mutation or another action?
twendy1
twendy1OP2w ago
Hey, I fixed it by changing from response.json() to response.text() and JSON.parse and also to sending different values to the next mutation. Yes, parts of response were going to another internal mutation, even thought it was something like customerInfo.subsriber.subscriptions, I think invalid value wasn't passed directly to the mutation.
dejeszio
dejeszio2w ago
Nice!

Did you find this page helpful?