S
Supabase•4d ago
static

Supabase gen types cannot read properties of undefined

What in the world would cause an error like this:
failed to retrieve generated types: {"message":"Cannot read properties of undefined (reading 'startsWith')","errorEventId":"2894dcfce0a045b5a0ad0935c543e9f8"}
Try rerunning the command with --debug to troubleshoot the error.
failed to retrieve generated types: {"message":"Cannot read properties of undefined (reading 'startsWith')","errorEventId":"2894dcfce0a045b5a0ad0935c543e9f8"}
Try rerunning the command with --debug to troubleshoot the error.
This is all I ran > supabase gen types typescript --project-id ... --schema public,messaging,stripe,autosend > ../types/src/supabase/supabase.ts
41 Replies
static
staticOP•4d ago
I see this when I check my postgres logs, and I've had this issue before but I can't seem to pinpoint where it tries to reference public.userprofile because everywhere in my code I do public."UserProfile". I'm sure the error is related because it always occurs the exact same time I run supabase gen types
No description
static
staticOP•4d ago
This is my --debug result:
No description
inder
inder•4d ago
What if you rename the table to lowercase letters? Does that work? When you create a table with double quotes around the name, it becomes case sensitive.
static
staticOP•4d ago
I guess I could make it lowercase/snake_case, I've just implemented it throughout so it just becomes a bit tedious
inder
inder•4d ago
this seems to be a bug with cli where its not passing the table name with quotes. Try renaming table name first to lowercase then we can be sure that its a bug with cli
static
staticOP•4d ago
Oh.. interesting, I just renamed it and the error went away in the logs however I still get the error in supabase gen types
static
staticOP•4d ago
No description
inder
inder•4d ago
Then the error you saw in your logs before was becuase of case sensitive table name. You should actually not create table names like that. snake case is best practice. Regarding the one you face now, maybe try again in a few minutes. I'm not sure but this could be because of some cache
static
staticOP•4d ago
Alright good to know for the table issue, and I've waiting like 20ish minutes so far. I thought it could've been just a issue then and took a break and came back to it
inder
inder•4d ago
Yeah wait a few minutes and then try. If it doesn't work, then I'd recommend to open an issue in supabase cli repo
static
staticOP•4d ago
Dang, okay. Is there any temporary fix you'd know of?
inder
inder•4d ago
You can try making an api request yourself https://supabase.com/docs/reference/api/v1-generate-typescript-types internally this is what supabase cli is doing
static
staticOP•4d ago
alright, cool thanks
inder
inder•4d ago
Try running this sql in dashboard sql editor and then try generating types
NOTIFY pgrst, 'reload schema';
NOTIFY pgrst, 'reload schema';
See if this works
static
staticOP•4d ago
Yeah, no good. I tried this twice to see if it would have a different result & I still get the same error
inder
inder•4d ago
I just thought that as the table name was updated so it'd be better to reload schema cache and see if that works. At this point you can wait for someone else if they have solution. Also try with a previous version of supabase cli if it was working for you before and you should open an issue in cli repo.
inder
inder•4d ago
You also have to option to generate types from dashboard https://supabase.com/dashboard/project/_/api?page=tables-intro
No description
static
staticOP•4d ago
Alright, I'll do that in the meantime Yeah, that makes sense. It was a good idea, I'll try to downgrade my supabase cli. Is this more of a bug than something on my end? oh my
static
staticOP•4d ago
No description
static
staticOP•4d ago
I genuinely wonder if I caused this by
inder
inder•4d ago
?
static
staticOP•4d ago
Oh sorry, didnt mean to leave the sentance hanging. I meant I wonder if I caused this on accident by updating an RPC function or something
inder
inder•4d ago
This seems to be an issue with your db. I just tested generating types from dashboard and it works. You should open a support request. They will be able to take a look at your db.
static
staticOP•4d ago
Do they normally have a long response rate? I'll go ahead and do that
inder
inder•4d ago
If you're on free plan, then there is no guaranteed response. Was this working before?
static
staticOP•4d ago
Yeah, this was working exactly last night I haven't upgraded any packages or anything
inder
inder•4d ago
And any db changes since last night?
static
staticOP•4d ago
Yeah, I've made some changes I'll have to do supabase db diff to see exactly whats next
inder
inder•4d ago
You should do that Also create a test project in the same region as your instance and create some test tables. Generate types for this new instance. That should also confirm this
static
staticOP•4d ago
I can show you changes if theres anything you might be able to pinpoint that could cause these issues
inder
inder•4d ago
You can post it here. I'm not a pro at postgres stuff but someone else might have an idea what is happening and is this because of db changes.
static
staticOP•4d ago
Fair, also your right. Just created a test project and I was able to generate types
inder
inder•4d ago
yeah seems to be your db related. I also googled about this issue and couldn't find anything about it.
static
staticOP•4d ago
😅.. this isn't the best news to hear
static
staticOP•4d ago
However, these are my changes https://pastebin.com/EmGmBcHF
Pastebin
set check_function_bodies = off;CREATE OR REPLACE FUNCTION autosend...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
inder
inder•4d ago
You should inline your code here in discord. Use markdown codeblocks. Some users don't like to click on links
static
staticOP•4d ago
Noted
static
staticOP•4d ago
inder
inder•4d ago
And what if you delete these changes you made since last night Looks like all are db functions
static
staticOP•4d ago
I've already pushed the changes so I wouldn't really be able to easily and do you think that could be the solution?
inder
inder•4d ago
You mention that type generation was working last night and these are the changes made since last night. But you're right about pushed changes. In the new test project you've created, push all migrations just before last night's see if then you can generate types and if that works, then push changes you made last night

Did you find this page helpful?