Undefined identifier: User

I am updating v0.13.2 to v0.14.0 and got the following error after following the migration guide:
1 errors found:
- /Users/rbatista19/Documents/VSCode/MeetingReminders/meeting-reminders/app/main.wasp @ 32:17-20
Type error:
Undefined identifier: User

31 | auth: {
32 | userEntity: User,
33 | methods: {
1 errors found:
- /Users/rbatista19/Documents/VSCode/MeetingReminders/meeting-reminders/app/main.wasp @ 32:17-20
Type error:
Undefined identifier: User

31 | auth: {
32 | userEntity: User,
33 | methods: {
24 Replies
MEE6
MEE65mo ago
Wohooo @Ricardo Batista, you just became a Waspeteer level 6!
kapa.ai
kapa.ai5mo ago
Hi @Ricardo Batista. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave: ---------------------- The error message you're seeing indicates that the User entity is not defined in your Wasp code. In Wasp, you need to declare a userEntity for all auth methods. This field tells Wasp which Entity represents the user. Here's an example of how you can define the User entity in your main.wasp file:
entity User {=psl
id Int @id @default(autoincrement())
// Add your own fields below
// ...
psl=}
entity User {=psl
id Int @id @default(autoincrement())
// Add your own fields below
// ...
psl=}
You can add any other fields you want to the user entity. Make sure to also define them in the userSignupFields field if they need to be set during the sign-up process. For more information, you can refer to the Wasp documentation on User Entity (https://wasp-lang.dev/docs/auth/social-auth/overview#user-entity). ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Ricardo Batista, 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?
Ricardo Batista
Ricardo BatistaOP5mo ago
When I do wasp version I still get:
Ricardos-MacBook-Pro:app rbatista19$ wasp version
0.13.2

If you wish to install/switch to the latest version of Wasp, do:
curl -sSL https://get.wasp-lang.dev/installer.sh | sh -s

If you want specific x.y.z version of Wasp, do:
curl -sSL https://get.wasp-lang.dev/installer.sh | sh -s -- -v x.y.z

Check https://github.com/wasp-lang/wasp/releases for the list of valid versions, including the latest one.
Ricardos-MacBook-Pro:app rbatista19$ wasp version
0.13.2

If you wish to install/switch to the latest version of Wasp, do:
curl -sSL https://get.wasp-lang.dev/installer.sh | sh -s

If you want specific x.y.z version of Wasp, do:
curl -sSL https://get.wasp-lang.dev/installer.sh | sh -s -- -v x.y.z

Check https://github.com/wasp-lang/wasp/releases for the list of valid versions, including the latest one.
IamIconLiving
IamIconLiving5mo ago
what happens when you try to upgrade the version of wasp? do you have any logs of success / failure? I tried to upgrade wasp myself right now and it worked ok
No description
martinsos
martinsos5mo ago
Yeah sounds like you are just now using newer version of Wasp, the question is why did you fail to upgrade it / what stopped you.
Ricardo Batista
Ricardo BatistaOP5mo ago
Damn, so simple @IamIconLiving 🌶 - sorry for not following the guide 🙏
IamIconLiving
IamIconLiving5mo ago
No worries! @martinsos how complex it is to implement an actual version check when running cli and suggest users to update it if it’s not latest?
Ricardo Batista
Ricardo BatistaOP5mo ago
Weird, now when building with wasp start I get
[ Wasp ] ext-src/client/admin/components/Header.tsx(1,15): error TS2305: Module '"wasp/auth/types"' has no exported member 'AuthUser'.
[ Wasp ] ext-src/client/admin/components/Header.tsx(1,15): error TS2305: Module '"wasp/auth/types"' has no exported member 'AuthUser'.
(cc @kapa.ai )
kapa.ai
kapa.ai5mo ago
Let me check the knowledge base for you. One moment! :books: ---------------------- The error message you're seeing indicates that the AuthUser member is not being exported from the wasp/auth/types module. This could be due to a few reasons: 1. The AuthUser member is not defined or not exported in the wasp/auth/types module. You should check the module to ensure that AuthUser is properly defined and exported. 2. There might be an issue with the path to the wasp/auth/types module. Make sure that the path is correct and that the module is properly installed. 3. It's also possible that there's a version mismatch or a bug in the Wasp framework. Make sure you're using the latest version of Wasp. If the problem persists, consider reporting the issue on the Wasp GitHub page (https://github.com/wasp-lang/wasp/issues). As a workaround, you can try cleaning the Wasp build artifacts and reinstalling the dependencies. You can do this by running wasp clean followed by wasp start as suggested in a Discord support thread (https://discord.com/channels/686873244791210014/1215750573278629958). If none of the above solutions work, it would be helpful to have more information about your project setup, such as the version of Wasp you're using and the contents of your wasp/auth/types module. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ---------------------- Sorry @Ricardo Batista, 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?
Tito
Tito5mo ago
Rename wasp/auth/types to wasp/auth
Ricardo Batista
Ricardo BatistaOP5mo ago
Spot on! And now getting:
[ Wasp ] server/operations/actions/index.ts(161,14): error TS2322: Type '(args: unknown, context: { user: AuthUser; }) => Promise<Payload>' is not assignable to type '(args: GenerateArticleParams, context: { user: AuthUser; }) => Promise<GenerateArticleResponse>'.
[ Wasp ] Type 'Promise<Payload>' is not assignable to type 'Promise<GenerateArticleResponse>'.
[ Wasp ] Type 'Payload' is not assignable to type 'GenerateArticleResponse'.
[ Wasp ] Type 'string' is not assignable to type 'GenerateArticleResponse'.
[ Wasp ] server/operations/actions/index.ts(161,57): error TS2344: Type '({ keywords, serviceSlug, name, userEmail, description, sitemapUrl, url, blog, internalLinkingStrength, localization, language, adherence, model, instructions, includeTocAndRelated, debug, frontmatterType, }: GenerateArticleParams) => Promise<GenerateArticleResponse>' does not satisfy the constraint 'GenericAuthenticatedOperationDefinition'.
[ Wasp ] Type 'Promise<GenerateArticleResponse>' is not assignable to type 'Payload | Promise<Payload>'.
[ Wasp ] Type 'Promise<GenerateArticleResponse>' is not assignable to type 'Symbol | Set<SuperJSONValue> | Map<SuperJSONValue, SuperJSONValue> | Promise<Payload>'.
[ Wasp ] Type 'Promise<GenerateArticleResponse>' is not assignable to type 'Promise<Payload>'.
[ Wasp ] Type 'GenerateArticleResponse' is not assignable to type 'Payload'.
[ Wasp ] Type 'GenerateArticleResponse' is not assignable to type 'SuperJSONObject'.
[ Wasp ] Index signature for type 'string' is missing in type 'GenerateArticleResponse'.
[ Wasp ] server/operations/actions/index.ts(161,14): error TS2322: Type '(args: unknown, context: { user: AuthUser; }) => Promise<Payload>' is not assignable to type '(args: GenerateArticleParams, context: { user: AuthUser; }) => Promise<GenerateArticleResponse>'.
[ Wasp ] Type 'Promise<Payload>' is not assignable to type 'Promise<GenerateArticleResponse>'.
[ Wasp ] Type 'Payload' is not assignable to type 'GenerateArticleResponse'.
[ Wasp ] Type 'string' is not assignable to type 'GenerateArticleResponse'.
[ Wasp ] server/operations/actions/index.ts(161,57): error TS2344: Type '({ keywords, serviceSlug, name, userEmail, description, sitemapUrl, url, blog, internalLinkingStrength, localization, language, adherence, model, instructions, includeTocAndRelated, debug, frontmatterType, }: GenerateArticleParams) => Promise<GenerateArticleResponse>' does not satisfy the constraint 'GenericAuthenticatedOperationDefinition'.
[ Wasp ] Type 'Promise<GenerateArticleResponse>' is not assignable to type 'Payload | Promise<Payload>'.
[ Wasp ] Type 'Promise<GenerateArticleResponse>' is not assignable to type 'Symbol | Set<SuperJSONValue> | Map<SuperJSONValue, SuperJSONValue> | Promise<Payload>'.
[ Wasp ] Type 'Promise<GenerateArticleResponse>' is not assignable to type 'Promise<Payload>'.
[ Wasp ] Type 'GenerateArticleResponse' is not assignable to type 'Payload'.
[ Wasp ] Type 'GenerateArticleResponse' is not assignable to type 'SuperJSONObject'.
[ Wasp ] Index signature for type 'string' is missing in type 'GenerateArticleResponse'.
(sorry to be pasting here these issues, but I am bit lost here)
Tito
Tito5mo ago
Those are typescript errors. It looks like that function is defined to return 'Promise<Payload>', but the actual return value of that function is different.
martinsos
martinsos5mo ago
@Ricardo Batista you migt want to check out migratino instructions here: https://wasp-lang.dev/docs/migrate-from-0-13-to-0-14 -> if you are on older verisn of Wasp like 0.12, then you will first want to check 0.12 to 0.13 and only then 0.13 to 0.14
Migration from 0.13.X to 0.14.X | Wasp
This guide only covers the migration from 0.13.X to 0.14.X. If you are migrating from 0.11.X or earlier, please read the migration guide from 0.11.X to 0.12.X first.
martinsos
martinsos5mo ago
Ha @IamIconLiving 🌶 that is actually a great question! The truth is, it is more complex than it should be, in hindsight :D. The thing is, Wasp parses the whole main.wasp file, and then extracts app.wasp.version from that and checks it. If it fails in parsing the file, it will throw parsing error before it ever gets to checking the version. Which looking back at it was a bad design, as you will get an error like unknown field app.db instead of getting wrong Wasp version, should be X but is Y. I see a couple of ways to avoid this out of the bat: 1. Take out specification of wasp version from the main.wasp file and have it somewhere else, maybe in additional wasp.version file or something like that. Could be in package.json in theory but I don't like that idea, I don't want package.json to act as a top level config file for the whole project, just for the JS part (which is most of the project but that might change in some ways in the future with polyglot stuff). 2. Have some kind of "pre-parsing" step that would parse main.wasp only for the version, ignoring then rest. This is probably the way to go, shouldn't be super hard, but is also not trivial but will take a couple of hours to properly implement, test and so on. 3. Simialr to (2), but istead of "pre-parsing", we inject additional piece of logic at the early phases of parsing (so once we have AST, but before CST), that check for version. So I would probably go for (3), but taking into accoutn that TS SDK is coming, and that we might drop Wasp DSL if TS SDK works well, it feels like it is best to just not spent time on it since it will anyway likely go into trash in a couple of months.
IamIconLiving
IamIconLiving5mo ago
Oh, sounds super complex. I was thinking for something way more simpler - whenever user runs wasp CLI (like wasp run), it quickly checks if user has latest cli version, and if not - spits out a message advising to update it with a url (while continuing its operation and starting up all the servers etc so it’s a non-disruptive operation). It might take a small hit on start up performance of wasp run I guess, but there are ways to minimize the damage
IamIconLiving
IamIconLiving5mo ago
actually good example is here
No description
Ricardo Batista
Ricardo BatistaOP5mo ago
Yes, I followed it - still had the errors I laid out here
martinsos
martinsos4mo ago
Ah got it taht is something else! Yeah that we should do this for sure, we actually have a Github issue for it, and this wouldn't be too hard to implement. Btw good way to reduce the impact of the check is to (1) do it in parallel with the rest of the command (non-blocking) and (2) remember when the last check was done and not do it again if it already happened that day. That is how we do telemetry right now. I ended up talking about something else -> about correctly detecting that they are using wrong verison at the moment.
Gwaggli
Gwaggli4mo ago
@Ricardo Batista Did you find a solution for your TypeScript errors? I just got the same after following the Migration being stuck at the migrate-dev command as it can't build the application.
Ricardo Batista
Ricardo BatistaOP4mo ago
It was stuff that was wrong already. Have a look at that code independently.
martinsos
martinsos4mo ago
@Gwaggli what exactlyi are you getting
Gwaggli
Gwaggli4mo ago
@martinsos I need to check back when I am at the Computer, but they were similar to the ones Ricardo posted. A mismatch between my Types and Payload.
server/operations/actions/index.ts(161,14): error TS2322: Type '(args: unknown, context: { user: AuthUser; }) => Promise<Payload>' is not assignable to type '(args: MyParamsRype, context: { user: AuthUser; }) => Promise<MyResponseType>'.
Type 'Promise<Payload>' is not assignable to type 'Promise<MyResponseType>'.
Type 'Payload' is not assignable to type 'MyResponseType'.
Type 'string' is not assignable to type 'MyResponseType'.
server/operations/actions/index.ts(161,14): error TS2322: Type '(args: unknown, context: { user: AuthUser; }) => Promise<Payload>' is not assignable to type '(args: MyParamsRype, context: { user: AuthUser; }) => Promise<MyResponseType>'.
Type 'Promise<Payload>' is not assignable to type 'Promise<MyResponseType>'.
Type 'Payload' is not assignable to type 'MyResponseType'.
Type 'string' is not assignable to type 'MyResponseType'.
martinsos
martinsos4mo ago
Hm! And can you share the code in question? Looks like "normal" Typescript error
Gwaggli
Gwaggli4mo ago
Hm somehow my answer seems to got lost. Sorry. I was able to single out the error in a sandbox and then resolve it. Thank you anyways! It was indeed a Typescript error that was let through before the update and caught with it.
Want results from more Discord servers?
Add your server