cli: [Bug]: shopify theme dev suddenly stopped working

Please confirm that you have:

  • Searched existing issues to see if your issue is a duplicate. (If you’ve found a duplicate issue, feel free to add additional information in a comment on it.)
  • Reproduced the issue in the latest CLI version.

In which of these areas are you experiencing a problem?

Theme

Expected behavior

I run shopify theme dev --store store-slug and a local development server is created for me to make changes on my machine.

Actual behavior

Error is thrown: Cannot read properties of undefined (reading ‘toString’). When I run the command with the --verbose flag, this is the last message before the error is thrown:

2023-03-24T22:55:52.557Z: Sending Identity Introspection request to URL: undefined

I’m assuming there should be a url in place of undefined.

Verbose output

2023-03-24T22:55:52.511Z: Running command theme dev
  shopify:theme:dev init version: @oclif/core@2.1.4 argv: [ '--store', 'store-slug, '--verbose' ] +0ms
2023-03-24T22:55:52.552Z: Ensuring that the user is authenticated with the Theme API with the following scopes:
[]

2023-03-24T22:55:52.552Z: Ensuring that the user is authenticated with the Admin API with the following scopes for the store store-slug.myshopify.com:
[]

2023-03-24T22:55:52.554Z: Getting session store...
2023-03-24T22:55:52.556Z: Validating existing session against the scopes:
[
  "openid",
  "https://api.shopify.com/auth/shop.admin.graphql",
  "https://api.shopify.com/auth/shop.admin.themes",
  "https://api.shopify.com/auth/partners.collaborator-relationships.readonly",
  "https://api.shopify.com/auth/shop.storefront-renderer.devtools",
  "https://api.shopify.com/auth/partners.app.cli.access"
]
For applications:
{
  "adminApi": {
    "scopes": [],
    "storeFqdn": "oakandeden.myshopify.com"
  }
}

2023-03-24T22:55:52.557Z: Sending Identity Introspection request to URL: undefined
╭─ error ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                          │
│  Cannot read properties of undefined (reading 'toString')                                                                                │
│                                                                                                                                          │
│  To investigate the issue, examine this stack trace:                                                                                     │
│    at shopifyFetch (../../../../usr/local/Cellar/shopify-cli/3.44.1/libexec/lib/node_modules/@shopify/theme/node_modules/@shopify/cli-k  │
│    it/src/public/node/http.ts:69)                                                                                                        │
│      outputDebug(outputContent`Sending ${options.method ?? 'GET'} request to URL ${url.toString()}                                       │
│    at (usr/local/Cellar/shopify-cli/3.44.1/libexec/lib/node_modules/@shopify/theme/node_modules/@shopify/cli-kit/dist/private/node/sess  │
│    ion/identity-token-validation.js:16)                                                                                                  │
│    at async withIntrospectionURL (../../../../usr/local/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 (../../../../usr/local/Cellar/shopify-cli/3.44.1/libexec/lib/node_modules/@shopify/theme/node_modules/@shop  │
│    ify/cli-kit/src/private/node/session/validate.ts:37)                                                                                  │
│      const identityIsValid = await validateIdentityToken(session.identity.accessToken)                                                   │
│    at async ensureAuthenticated (../../../../usr/local/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 (../../../../usr/local/Cellar/shopify-cli/3.44.1/libexec/lib/node_modules/@shopify/theme/node_modu  │
│    les/@shopify/cli-kit/src/public/node/session.ts:82)                                                                                   │
│      const tokens = await ensureAuthenticated({adminApi: {scopes, storeFqdn: store}}, process.env, forceRefresh)                         │
│    at run (../../../../usr/local/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)                                               │
│                                                                                                                                          │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

2023-03-24T22:55:52.629Z: Unable to log analytics event - no information on executed command
2023-03-24T22:55:52.648Z: Failed to report usage analytics: Couldn't find a a package.json traversing directories from /Users/briancook/repos/oak_and_eden
2023-03-24T22:55:52.648Z: Completed command theme dev
2023-03-24T22:55:52.659Z: There was an error adding metadata to the Bugsnag report; Ignoring and carrying on Error: Couldn't find a a package.json traversing directories from /Users/briancook/repos/oak_and_eden

Reproduction steps

  1. Upgrade to latest Shopify CLI version (3.44.1)
  2. Run shopify auth logout
  3. Run shopify theme dev --store store-slug

Operating System

Mac OS Ventura 13.2.1

Shopify CLI version (check your project’s package.json if you’re not sure)

3.44.1

Shell

zsh

Node version (run node -v if you’re not sure)

v15.14.0

What language and version are you using in your application?

No response

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (7 by maintainers)

Most upvoted comments

@gonzaloriestra I also deleted the file from my trash but as @brianecook mentioned, I vaguely remember this but the timestamp was there and the value was empty. Will make a note if this occurs again.

@gonzaloriestra Unfortunately, I don’t recall exactly what it was before I deleted it, but it was a number about ten digits long. Maybe an ID or a timestamp?

Given you’re on Mac OS, you should have a file at ~/Library/Preferences/shopify-cli-kit-nodejs/config.json with a value like "identity-introspection-url-accounts.shopify.com". Can you please:

  1. Confirm that it’s there, and report back in a comment what it contains?
  2. See if deleting that entry from the cache fixes your problem? (Or you can delete the entire file, which will just reset your session and you’ll have to login again. A bit of a blunt approach, but less danger of ending up with a corrupted file.)