ibbyreact
ibbyreact6mo ago

hi tema,

hi tema, I am using clerk/backend and when i use const response = await clerkClient.invitations.getInvitationList(); I am getting a convex error in the logs "[Request ID: 8eeb178508e8f37a] Server Error Uncaught Error: _Invitation {"id":"inv_2lYsQsr83hXeMCBdPO9uEt5nzgT","emailAddress":"ibrahim.s.amin@gmail.com","publicMetadata":{"type":"client"},"createdAt":1725368330622,"updatedAt":1725368330622,"status":"pending","revoked":"undefined"} is not a supported Convex type (present at path .data[0] in original object {"data":[{"id":"inv_2lYsQsr83hXeMCBdPO9uEt5nzgT","emailAddress":"ibrahim.s.amin@gmail.com","publicMetadata":{"type":"client"},"createdAt":1725368330622,"updatedAt":1725368330622,"status":"pending","revoked":"undefined"},{"id":"inv_2lYnM1xCtU0hagy9Lqw0Gsy5O9w","emailAddress":"ibrahim@marvelhomes.com.au","publicMetadata":{"type":"client"},"createdAt":1725365825401,"updatedAt":1725365883582,"status":"accepted","revoked":"undefined"}],"totalCount":2}). To learn about Convex's supported types, see https://docs.convex.dev/using/types." yes when i use const response = await clerkClient.users.getUserList(); i dont get any errors. the functions are working, any advise would be much appreciated p.s loving convex and how easy to use Thanks
20 Replies
nipunn
nipunn6mo ago
Hi. It may be helpful if you can include more of the function. My guess is that undefined is not a valid datatype which is noted here https://docs.convex.dev/database/types (search undefined) But it's merely a guess based on the error message - would need more information to validate. You could try unsetting the "revoked" column, or setting it to null.
Data Types | Convex Developer Hub
All Convex documents are defined as Javascript objects. These objects can have
nipunn
nipunn6mo ago
Data types are only relevant when returning the value or trying to write it to the database - so based on the code snippet you gave so far, it's not clear where that would be happening.
ibbyreact
ibbyreactOP6mo ago
this is the funciton. i am trying to get a list of all the results back so i can use it in my react front end export const getInvitations = action({ handler: async () => { const response = await clerkClient.invitations.getInvitationList(); const result = response; console.log('INVITATIONS', response); return result.data; }, });
nipunn
nipunn6mo ago
nice - what does the console.log look like?
ibbyreact
ibbyreactOP6mo ago
'INVITATIONS' { data: [ _Invitation { id: 'inv_2lYsQsr83hXeMCBdPO9uEt5nzgT', emailAddress: 'ibrahim.s.amin@gmail.com', publicMetadata: [Object], createdAt: 1725368330622, updatedAt: 1725368330622, status: 'pending', revoked: undefined }, _Invitation { id: 'inv_2lYnM1xCtU0hagy9Lqw0Gsy5O9w', emailAddress: 'ibrahim@marvelhomes.com.au', publicMetadata: [Object], createdAt: 1725365825401, updatedAt: 1725365883582, status: 'accepted', revoked: undefined } ], totalCount: 2 }
ibbyreact
ibbyreactOP6mo ago
and this is waht i get in convex dash
No description
ibbyreact
ibbyreactOP6mo ago
No description
nipunn
nipunn6mo ago
I bet _Invitation isn't a regular javascript object - has to be a javascript object in order to return it. That is annoying and nonobvious from the error though. I wonder if getInvitationList docs have info
ibbyreact
ibbyreactOP6mo ago
btw, i am a noob and teaching myself how to program so i can build a tool for my business.. so i might have some fundamentals erros
ibbyreact
ibbyreactOP6mo ago
this is the promess from getInvitationList()
No description
nipunn
nipunn6mo ago
nah - this is indeed something confusing happening.
ibbyreact
ibbyreactOP6mo ago
btw, i added a retun response for this export const getUsers = action({ handler: async () => { const response = await clerkClient.users.getUserList(); console.log('USERS', response); return response.data; }, }); and now i get the same error if i remove the return respose the error dispear
nipunn
nipunn6mo ago
yeah - it's coming from Convex because convex has to get the return value from the server function -> client I asked GPT and got some suggestions
const invitationInstance = new _Invitation(
'inv_2lYsQsr83hXeMCBdPO9uEt5nzgT',
'ibrahim.s.amin@gmail.com',
{ some: 'metadata' },
1725368330622,
1725368330622,
'pending',
undefined
);

// Convert the instance to a plain object
const invitationObject = { ...invitationInstance };
console.log(invitationObject);
const invitationInstance = new _Invitation(
'inv_2lYsQsr83hXeMCBdPO9uEt5nzgT',
'ibrahim.s.amin@gmail.com',
{ some: 'metadata' },
1725368330622,
1725368330622,
'pending',
undefined
);

// Convert the instance to a plain object
const invitationObject = { ...invitationInstance };
console.log(invitationObject);
so maybe something like
const invitationObject = { ...invitationInstance };
const invitationObject = { ...invitationInstance };
could be the key to being able to return what you want - as it converts it to an object you can also just pull out the fields you care about into an object and just return that manually - and that will work
ibbyreact
ibbyreactOP6mo ago
maybe becasue it has "" that is throwing an error with conves as my understanding the "" is reserved to convex system
nipunn
nipunn6mo ago
GPT is pretty good - this probably will work
No description
nipunn
nipunn6mo ago
(this is the question I asked)
No description
ibbyreact
ibbyreactOP6mo ago
let me try it thanks yeah it fixed it thanks heaps
v
v6mo ago
its probably because Invitationis a class
ibbyreact
ibbyreactOP6mo ago
right

Did you find this page helpful?