Shopify / shopify-cli

Shopify CLI helps you build against the Shopify platform faster.
https://shopify.dev/tools/cli
Other
1.01k stars 201 forks source link

[Bug] theme dev is throwing a TypeError and causing auth issue #2740

Closed aprilalayon closed 1 year ago

aprilalayon commented 1 year ago

Issue summary

Write a short description of the issue here ↓

Theres seems to be an issue with authorization. My local was working fine yesterday and today I ran shopify theme dev and this TypeError is blocking me.

Everything is up to date, Homebrew, Shopify CLI, Node (tried different Node versions), Logged out of Shopify CLI and ran shopify theme dev again but it's still erroring out. I've cleared all my cache and restarted my machine.

NOTE: I already ran `shopify theme dev --store flag

I am running out of ideas to try. Any help would be appreciated!

Expected behavior

What do you think should happen? It's expected to build my dev site and give me my local and preview links after I run shopify theme dev

Actual behavior

What actually happens?

The process fails at Sending Identity Introspection request to URL: undefined and throws an error

TypeError: Cannot read properties of undefined (reading 'toString') at shopifyFetch (file:///opt/homebrew/Cellar/shopify-cli/3.44.1/libexec/lib/node_modules/@shopify/theme/node_modules/@shopify/cli-kit/dist/public/node/http.js:50:88) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async file:///opt/homebrew/Cellar/shopify-cli/3.44.1/libexec/lib/node_modules/@shopify/theme/node_modules/@shopify/cli-kit/dist/private/node/session/identity-token-validation.js:16:30 at async withIntrospectionURL (file:///opt/homebrew/Cellar/shopify-cli/3.44.1/libexec/lib/node_modules/@shopify/theme/node_modules/@shopify/cli-kit/dist/private/node/session/identity-token-validation.js:48:18) at async validateSession (file:///opt/homebrew/Cellar/shopify-cli/3.44.1/libexec/lib/node_modules/@shopify/theme/node_modules/@shopify/cli-kit/dist/private/node/session/validate.js:26:29) at async ensureAuthenticated (file:///opt/homebrew/Cellar/shopify-cli/3.44.1/libexec/lib/node_modules/@shopify/theme/node_modules/@shopify/cli-kit/dist/private/node/session.js:44:30) at async ensureAuthenticatedStorefront (file:///opt/homebrew/Cellar/shopify-cli/3.44.1/libexec/lib/node_modules/@shopify/theme/node_modules/@shopify/cli-kit/dist/public/node/session.js:44:20) at async Dev.execute (file:///opt/homebrew/Cellar/shopify-cli/3.44.1/libexec/lib/node_modules/@shopify/theme/dist/cli/commands/theme/dev.js:50:33)

Steps to reproduce the problem

  1. run shopify theme dev
  2. error appears

OR

  1. run shopify auth logout
  2. run shopify theme dev
  3. Shopify CLI log in appears on browser
  4. Logs in with my account
  5. Browser tells me I am logged in and I can go back to my terminal
  6. Terminal shows the TypeError.

Stacktrace

│  Cannot read properties of undefined (reading 'toString')                    
│                                                                              
│  To investigate the issue, examine this stack trace:                         
│    at shopifyFetch (../../../opt/homebrew/Cellar/shopify-cli/3.44.1/libexec  
│    /lib/node_modules/@shopify/theme/node_modules/@shopify/cli-kit/src/publi  
│    c/node/http.ts:69)                                                        
│      outputDebug(outputContent`Sending ${options.method ?? 'GET'} request    
│      to URL ${url.toString()}                                                
│    at (opt/homebrew/Cellar/shopify-cli/3.44.1/libexec/lib/node_modules/@sho  
│    pify/theme/node_modules/@shopify/cli-kit/dist/private/node/session/ident  
│    ity-token-validation.js:16)                                               
│    at async withIntrospectionURL (../../../opt/homebrew/Cellar/shopify-cli/  
│    3.44.1/libexec/lib/node_modules/@shopify/theme/node_modules/@shopify/cli  
│    -kit/src/private/node/session/identity-token-validation.ts:49)            
│      let result: Result<T, AbortError> = await fn(introspectionURL)          
│    at async validateSession (../../../opt/homebrew/Cellar/shopify-cli/3.44.  
│    1/libexec/lib/node_modules/@shopify/theme/node_modules/@shopify/cli-kit/ 
│    src/private/node/session/validate.ts:37)                                  
│      const identityIsValid = await                                           
│      validateIdentityToken(session.identity.accessToken)                    
│    at async ensureAuthenticated (../../../opt/homebrew/Cellar/shopify-cli/3  
│    .44.1/libexec/lib/node_modules/@shopify/theme/node_modules/@shopify/cli-  
│    kit/src/private/node/session.ts:113)                                     
│      const validationResult = await validateSession(scopes, applications,    
│      fqdnSession)                                                            
│    at async ensureAuthenticatedAdmin (../../../opt/homebrew/Cellar/shopify-  
│    cli/3.44.1/libexec/lib/node_modules/@shopify/theme/node_modules/@shopify  
│    /cli-kit/src/public/node/session.ts:82)                                  
│      const tokens = await ensureAuthenticated({adminApi: {scopes,            
│      storeFqdn: store}}, process.env, forceRefresh)                          
│    at run (../../../opt/homebrew/Cellar/shopify-cli/3.44.1/libexec/lib/node  
│    _modules/@shopify/theme/src/cli/commands/theme/dev.ts:103)                
│      const adminSession = await ensureAuthenticatedThemes(store,             
│      flags.password, [], true)                                               

Specifications

amcaplan commented 1 year ago

@aprilalayon thanks for the report! I'm closing as a duplicate of https://github.com/Shopify/cli/issues/1664 which I'd recommend you follow.

Note that future CLI 3 issues should be reported on that repo.

gonzaloriestra commented 1 year ago

@aprilalayon could you please follow these steps?

aprilalayon commented 1 year ago

@amcaplan @gonzaloriestra I followed the solution from https://github.com/Shopify/cli/issues/1664 and it worked for me. Thank you for the quick follow up. I will note about any future CLI 3 issues be addressed on that repo.