epicweb-dev / react-fundamentals

Material for my React Fundamentals Workshop
https://fundamentals.epicreact.dev
Other
5.3k stars 3.21k forks source link

Zod Error after authenticating #393

Closed a1994lex closed 1 month ago

a1994lex commented 1 month ago

node v20.8.1 git v2.42.0 npm v10.1.0

What I expected: To be able to access the dashboard on the app after linking my account.

What happened: Ran setup successfully, error occurred after attempting to link account. I was not logged in to epic dev initially, so clicking the link from the app had me log in, I did this by logging in via email address. After confirming that the passkey was the same on the app, I navigated back to my app and the words "Unexpected Server Error" appear on the local web page. I've tried deleting project, and re-running setup, clearing cache, still always get the same error.

Terminal error says this:

ZodError: [ { "code": "invalid_type", "expected": "object", "received": "null", "path": [ "discordProfile" ], "message": "Expected object, received null" } ] at Object.get error [as error] (file:///Users/alexwilson/personal/learning/react-fundamentals/epicshop/node_modules/zod/lib/index.mjs:587:31) at ZodEffects.parse (file:///Users/alexwilson/personal/learning/react-fundamentals/epicshop/node_modules/zod/lib/index.mjs:692:22) at getFreshValue (file:///Users/alexwilson/personal/learning/react-fundamentals/epicshop/node_modules/@epic-web/workshop-app/app/utils/epic-api.ts:640:26) at processTicksAndRejections (node:internal/process/task_queues:95:5) at getFreshValue (file:///Users/alexwilson/personal/learning/react-fundamentals/epicshop/node_modules/@epic-web/cachified/src/getFreshValue.ts:17:24) at Module.cachified (file:///Users/alexwilson/personal/learning/react-fundamentals/epicshop/node_modules/@epic-web/cachified/src/cachified.ts:89:17) at file:///Users/alexwilson/personal/learning/react-fundamentals/epicshop/node_modules/remix-utils/build/common/promise.js:30:106 at async Promise.all (index 3) at promiseHash (file:///Users/alexwilson/personal/learning/react-fundamentals/epicshop/node_modules/remix-utils/build/common/promise.js:30:31) at loader$y (file:///Users/alexwilson/personal/learning/react-fundamentals/epicshop/node_modules/@epic-web/workshop-app/app/root.tsx:106:21) { issues: [ { code: 'invalid_type', expected: 'object', received: 'null', path: [Array], message: 'Expected object, received null' } ], addIssue: [Function (anonymous)], addIssues: [Function (anonymous)], errors: [ { code: 'invalid_type', expected: 'object', received: 'null', path: [Array], message: 'Expected object, received null' } ] }

kentcdodds commented 1 month ago

Hi @a1994lex. I pushed a bad validation. This has been fixed. Can you try to update?

npx update-epic-workshop
a1994lex commented 1 month ago

Hi @kentcdodds ! Yeah I updated and I am still getting same error. Wondering if there is some additional cache I need to clean besides browser cache and npm cache

containerpope commented 1 month ago

@kentcdodds I also cloned the repository and executed npx update-epic-workshop. Even after deleting the cache (~/.epicshop) I still see the error page.

image

See output below


matthias@AirvonMatthias react-fundamentals % npx update-epic-workshop
Need to install the following packages:
update-epic-workshop@5.3.2
Ok to proceed? (y) y

✅ No updates available.
matthias@AirvonMatthias react-fundamentals % rm -rf ~/.epicshop 
matthias@AirvonMatthias react-fundamentals % npm run start           

> start
> npx --prefix ./epicshop epicshop start

🐨  Let's get learning!
Local:            http://localhost:5639
On Your Network:  http://10.150.0.254:5639
Press Ctrl+C to stop
ZodError: [
  {
    "code": "invalid_type",
    "expected": "object",
    "received": "null",
    "path": [
      "discordProfile"
    ],
    "message": "Expected object, received null"
  }
]
    at Object.get error [as error] (file:///Users/matthias/work/training/epic-react/react-fundamentals/epicshop/node_modules/zod/lib/index.mjs:587:31)
    at ZodEffects.parse (file:///Users/matthias/work/training/epic-react/react-fundamentals/epicshop/node_modules/zod/lib/index.mjs:692:22)
    at getFreshValue (file:///Users/matthias/work/training/epic-react/react-fundamentals/epicshop/node_modules/@epic-web/workshop-app/app/utils/epic-api.ts:638:26)
    at processTicksAndRejections (node:internal/process/task_queues:105:5)
    at getFreshValue (file:///Users/matthias/work/training/epic-react/react-fundamentals/epicshop/node_modules/@epic-web/cachified/src/getFreshValue.ts:17:24) {
  issues: [
    {
      code: 'invalid_type',
      expected: 'object',
      received: 'null',
      path: [Array],
      message: 'Expected object, received null'
    }
  ],
  addIssue: [Function (anonymous)],
  addIssues: [Function (anonymous)],
  errors: [
    {
      code: 'invalid_type',
      expected: 'object',
      received: 'null',
      path: [Array],
      message: 'Expected object, received null'
    }
  ]
}
andrerfcsantos commented 1 month ago

I'm also having this issue, being on the most recent commit on the main branch.

The most recent commit that works for me is commit 733e35ba7d034178d1ac726897bd795ff784f1b3

So as a workaround, you can do:

$ git reset --hard 733e35 # resets your current branch to this commit 
$ npm install
$ npm start

EDIT: Switched the git switch command to a git reset so npm start doesn't throw an warning saying "HEAD does not point to a branch"

kentcdodds commented 1 month ago

So sorry! I missed another thing on the validation. This is terribly embarrassing. I promise it should be fixed now! Please let me know if it is not.

andrerfcsantos commented 1 month ago

@kentcdodds Still not working for me

C5m7b4 commented 1 month ago

I am having the same issue here. Can't wait to get started after this is resolved though.

kentcdodds commented 1 month ago

My mistake. I just realized the discord profile should be optional and nullable 🤦‍♂️

Anyway, that should be fixed now for realzies this time.

juanruben commented 1 month ago

Nice! Thank you. It is working now

kentcdodds commented 1 month ago

That's such a relief 😅