Supabase gen types cannot read properties of undefined
What in the world would cause an error like this:
This is all I ran
> supabase gen types typescript --project-id ... --schema public,messaging,stripe,autosend > ../types/src/supabase/supabase.ts41 Replies
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

This is my --debug result:

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.
I guess I could make it lowercase/snake_case, I've just implemented it throughout so it just becomes a bit tedious
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
Oh.. interesting, I just renamed it and the error went away in the logs however I still get the error in supabase gen types

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
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
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
Dang, okay. Is there any temporary fix you'd know of?
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
alright, cool thanks
Try running this sql in dashboard sql editor and then try generating types
See if this works
Yeah, no good. I tried this twice to see if it would have a different result & I still get the same error
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.
You also have to option to generate types from dashboard https://supabase.com/dashboard/project/_/api?page=tables-intro

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

I genuinely wonder if I caused this by
?
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
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.
Do they normally have a long response rate?
I'll go ahead and do that
If you're on free plan, then there is no guaranteed response.
Was this working before?
Yeah, this was working exactly last night
I haven't upgraded any packages or anything
And any db changes since last night?
Yeah, I've made some changes
I'll have to do supabase db diff to see exactly whats next
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
I can show you changes if theres anything you might be able to pinpoint that could cause these issues
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.
Fair, also your right.
Just created a test project and I was able to generate types
yeah seems to be your db related. I also googled about this issue and couldn't find anything about it.
😅.. this isn't the best news to hear
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.
You should inline your code here in discord. Use markdown codeblocks. Some users don't like to click on links
Noted
And what if you delete these changes you made since last night
Looks like all are db functions
I've already pushed the changes so I wouldn't really be able to easily and do you think that could be the solution?
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