Invalid discriminator value. Expected 'development' | 'production'
Hey everyone I'm trying out wasp and sadhly on version: "^0.16.0" everytime i try to run a db seed following:
https://wasp.sh/docs/data-model/backends#seeding-the-database
I always get
❯ wasp db seed devSeedSimple
[ Db ] Environment variables loaded from .env
[ Db ] Running seed command
npm run db-seed ...
[ Db ]
[ Db ] > [email protected] db-seed
[ Db ] > npm run bundle && node --enable-source-maps -r dotenv/config bundle/dbSeed.js
[ Db ]
[ Db ]
[ Db ] > [email protected] bundle
[ Db ] > rollup --config --silent
[ Db ]
[ Db !]
[ Db !] ══ Env vars validation failed ══
[ Db !]
[ Db !] - Invalid discriminator value. Expected 'development' | 'production'
[ Db !]
[ Db !] ════════════════════════════════
[ Db !] /Volumes/Sensitive/Development/.wasp/out/sdk/wasp/env/validation.ts:20
[ Db !] throw new Error('Error parsing environment variables')
[ Db !] ^
[ Db !]
[ Db !]
[ Db !] Error: Error parsing environment variables
[ Db !] at ensureEnvSchema (/Volumes/Sensitive/Development/work/.wasp/out/sdk/wasp/env/validation.ts:20:13)
[ Db !] at <anonymous> (/Volumes/Sensitive/Development/work/.wasp/out/sdk/wasp/server/env.ts:68:20)
[ Db !] at ModuleJob.run (node:internal/modules/esm/module_job:272:25)
[ Db !] at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:583:26)
[ Db !] at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:98:5)
[ Db !]
[ Db !] Node.js v23.7.0
[ Db !]
[ Db !] An error occurred while running the seed command:
[ Db !] Error: Command failed with exit code 1: npm run db-seed
❌ --- [Error] Database seeding failed: -------------------------------------------
Failed with exit code 1
Databases | Wasp
Entities, Operations and Automatic CRUD together make a high-level interface for working with your app's data. Still, all that data has to live somewhere, so let's see how Wasp deals with databases.
7 Replies
Hi @seppulcro. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Based on the error message you're seeing, it appears that there's an issue with the environment variables in your Wasp project. The error suggests that the discriminator value for the environment is invalid. Let's try to resolve this issue step by step.
1. First, make sure you have a
.env.server
file in the root of your Wasp project. If it doesn't exist, create one.
2. In the .env.server
file, you need to set the NODE_ENV
variable. It should be either "development" or "production". For local development, you typically want to use "development". Add this line to your .env.server
file:
3. If you already have a .env.server
file, check if the NODE_ENV
variable is set correctly. Make sure there are no typos and that the value is exactly "development" or "production".
4. After making these changes, try running wasp db seed devSeedSimple
again.
If the issue persists, you can try the following additional steps:
5. Run wasp clean
to clear any cached data.
6. Then run wasp start
to ensure everything is set up correctly.
7. Finally, try the seed command again: wasp db seed devSeedSimple
If you're still encountering issues, it might be helpful to check the Wasp documentation on environment variables for any additional configuration that might be necessary.
Remember, environment variables in Wasp are loaded from .env.server
for the server and .env.client
for the client. Make sure you're setting the server-side variables in the correct file.
If none of these steps resolve the issue, it might be worth checking if there's a bug in the specific version of Wasp you're using (^0.16.0). You could try updating to the latest version of Wasp if possible, or check the Wasp GitHub issues to see if this is a known problem.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @seppulcro, 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?Welp the AI answer did help, setting a .env.server with
NODE_ENV=development
But i cannot for the life of me find any reference to this in the docs?
But i cannot for the life of me find any reference to this in the docs?
Yep, it's a bug that just caught ourselves 🤦🏻♂️ we didn't set the default value properly for NODE_ENV.
Thank you for understanding, the fix will go out soon with 0.16.3
No problem!
I'll also update the docs to reflect how to use prisma client for types and or enums set in the schema.
Seems like sanitizeAndSerializeProviderData is also not working as expected or maybe the docs are out of date?
It needs an await 🙂
Could you link to the place in the docs where we didn't use
await
? I see here https://wasp.sh/docs/auth/entities#custom-signup-action that we use await
Accessing User Data | Wasp
First, we'll check out the most practical info: how to access the user's data in your app.
Thanks for the report, I'll create an issue for to fix it 👍