Shopify / cli

Build apps, themes, and hydrogen storefronts for Shopify
https://shopify.dev
MIT License
411 stars 125 forks source link

[Bug]: Cannot run `shopify app dev` #4324

Closed patrick-r-son closed 1 month ago

patrick-r-son commented 1 month ago

Please confirm that you have:

In which of these areas are you experiencing a problem?

Extension

Expected behavior

Running shopify app dev should open my app in development mode

Actual behavior

The command fails with the error "Couldn't find the app with Client ID a37713c7a190c925231a282fb793e1dc", which doesn't match the client ID of my app.

Verbose output

2024-08-13T20:45:34.050Z: Running command app dev
╭─ warning ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                        │
│  The flag `api-key` has been deprecated in favor of `client-id`                                                                                                                        │
│                                                                                                                                                                                        │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

2024-08-13T20:45:34.071Z: Getting a random port...
2024-08-13T20:45:34.076Z: Random port obtained: 56783
2024-08-13T20:45:34.116Z: cloudflared already installed, skipping
2024-08-13T20:45:34.119Z: 
Running system process:
  · Command: /Users/patrick.son/.nvm/versions/node/v20.13.1/lib/node_modules/@shopify/cli/bin/cloudflared tunnel --url http://localhost:56783 --no-autoupdate
  · Working directory: /Users/patrick.son/Klaviyo/Repos/atlas/customer-hub-widgets

2024-08-13T20:45:34.122Z: Reading cached app information for directory /Users/patrick.son/Klaviyo/Repos/atlas/customer-hub-widgets...
2024-08-13T20:45:34.123Z: Reading the content of file at shopify.app.toml...
2024-08-13T20:45:34.125Z: Reading the content of file at shopify.app.toml...
2024-08-13T20:45:34.154Z: 2024-08-13T20:45:34Z INF Thank you for trying Cloudflare Tunnel. Doing so, without a Cloudflare account, is a quick way to experiment and try it out. However, be aware that these account-less Tunnels have no uptime guarantee. If you intend to use Tunnels in production you should use a pre-created named tunnel by following: https://developers.cloudflare.com/cloudflare-one/connections/connect-apps
2024-08-13T20:45:34Z INF Requesting new quick Tunnel on trycloudflare.com...

2024-08-13T20:45:34.194Z: Reading cached app information for directory /Users/patrick.son/Klaviyo/Repos/atlas/customer-hub-widgets...
2024-08-13T20:45:34.195Z: Reading cached app information for directory /Users/patrick.son/Klaviyo/Repos/atlas/customer-hub-widgets...
2024-08-13T20:45:34.196Z: Reading cached app information for directory /Users/patrick.son/Klaviyo/Repos/atlas/customer-hub-widgets...
2024-08-13T20:45:34.196Z: Reading the content of file at shopify.app.toml...
2024-08-13T20:45:34.197Z: Reading the content of file at shopify.app.toml...
2024-08-13T20:45:34.268Z: Ensuring that the user is authenticated with the Partners API with the following scopes:
[]

2024-08-13T20:45:34.268Z: Getting session store...
2024-08-13T20:45:34.269Z: 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",
  "https://api.shopify.com/auth/destinations.readonly"
]
For applications:
{
  "partnersApi": {
    "scopes": []
  }
}

2024-08-13T20:45:34.269Z: Sending Identity Introspection request to URL: https://accounts.shopify.com/oauth/introspection
2024-08-13T20:45:34.269Z: Sending POST request to URL https://accounts.shopify.com/oauth/introspection
With request headers:
 - User-Agent: Shopify CLI; v=3.65.3
 - Keep-Alive: timeout=30
 - Sec-CH-UA-PLATFORM: darwin
 - Content-Type: application/json

2024-08-13T20:45:34.393Z: Request to https://accounts.shopify.com/oauth/introspection completed in 121 ms
With response headers:
 - cache-control: no-cache, no-store, private, must-revalidate, max-age=0
 - content-type: application/json; charset=utf-8
 - etag: W/"8829de07feb780ec4a1d99070fcabc1a"
 - x-request-id: 9f6974f8-2579-48b9-bebb-9733afce6d3b-1723581934

2024-08-13T20:45:34.397Z: The identity token is valid: true
2024-08-13T20:45:34.397Z: 
The validation of the token for application/identity completed with the following results:
- It's expired: false
- It's invalid in identity: false

2024-08-13T20:45:34.397Z: Verifying that the user has a Partner organization
2024-08-13T20:45:34.402Z: Sending "Partners" GraphQL request:
  {
    organizations(first: 1) {
      nodes {
        id
      }
    }
  }

With request headers:
 - User-Agent: Shopify CLI; v=3.65.3
 - Keep-Alive: timeout=30
 - Sec-CH-UA-PLATFORM: darwin
 - Content-Type: application/json

2024-08-13T20:45:34.560Z: Request to https://partners.shopify.com/api/cli/graphql completed in 147 ms
With response headers:
 - cache-control: max-age=0, private, must-revalidate
 - content-type: application/json; charset=utf-8
 - etag: W/"98032ab2090e5e60f6be7356693e7d1d"
 - x-request-id: 82e1e3d0-b0b6-4cf6-a44b-da2897bcfab6-1723581934

2024-08-13T20:45:34.565Z: Sending "Partners" GraphQL request:
  query currentAccountInfo {
    currentAccountInfo {
      __typename
      ... on ServiceAccount {
        orgName
      }
      ... on UserAccount {
        email
      }
    }
  }

With request headers:
 - User-Agent: Shopify CLI; v=3.65.3
 - Keep-Alive: timeout=30
 - Sec-CH-UA-PLATFORM: darwin
 - Content-Type: application/json

2024-08-13T20:45:34.652Z: Request to https://partners.shopify.com/api/cli/graphql completed in 85 ms
With response headers:
 - cache-control: max-age=0, private, must-revalidate
 - content-type: application/json; charset=utf-8
 - etag: W/"0949b073c2c971e08cce5e62a0810e5e"
 - x-request-id: 7b4a0ef2-702b-46a4-b24c-8aa5ccb88a09-1723581934

2024-08-13T20:45:34.716Z: Sending "Partners" GraphQL request:
  query FindApp($apiKey: String!) {
    app(apiKey: $apiKey) {
      id
      title
      apiKey
      organizationId
      apiSecretKeys {
        secret
      }
      appType
      grantedScopes
      applicationUrl
      redirectUrlWhitelist
      requestedAccessScopes
      webhookApiVersion
      embedded
      posEmbedded
      preferencesUrl
      gdprWebhooks {
        customerDeletionUrl
        customerDataRequestUrl
        shopDeletionUrl
      }
      appProxy {
        subPath
        subPathPrefix
        url
      }
      developmentStorePreviewEnabled
      disabledFlags
    }
  }

With variables:
{
  "apiKey": "*****"
}

With request headers:
 - User-Agent: Shopify CLI; v=3.65.3
 - Keep-Alive: timeout=30
 - Sec-CH-UA-PLATFORM: darwin
 - Content-Type: application/json

2024-08-13T20:45:35.413Z: Request to https://partners.shopify.com/api/cli/graphql completed in 696 ms
With response headers:
 - cache-control: max-age=0, private, must-revalidate
 - content-type: application/json; charset=utf-8
 - etag: W/"d7924c5ecb00aff9958bb88e845f5b5d"
 - x-request-id: 6d75dfc2-b8ca-43c8-b2d4-ea243638c926-1723581934

2024-08-13T20:45:35.420Z: Sending "Partners" GraphQL request:
  query FindOrganization($id: ID!) {
    organizations(id: $id, first: 1) {
      nodes {
        id
        businessName
      }
    }
  }

With variables:
{
  "id": "3647805"
}

With request headers:
 - User-Agent: Shopify CLI; v=3.65.3
 - Keep-Alive: timeout=30
 - Sec-CH-UA-PLATFORM: darwin
 - Content-Type: application/json

2024-08-13T20:45:35.513Z: Request to https://partners.shopify.com/api/cli/graphql completed in 91 ms
With response headers:
 - cache-control: max-age=0, private, must-revalidate
 - content-type: application/json; charset=utf-8
 - etag: W/"3855bfacf7d0b6d979b0d619a02f193b"
 - x-request-id: ffa2285f-155a-4489-897e-86783df31926-1723581935

2024-08-13T20:45:35.569Z: Sending "Partners" GraphQL request:
  query FindApp($apiKey: String!) {
    app(apiKey: $apiKey) {
      id
      title
      apiKey
      organizationId
      apiSecretKeys {
        secret
      }
      appType
      grantedScopes
      applicationUrl
      redirectUrlWhitelist
      requestedAccessScopes
      webhookApiVersion
      embedded
      posEmbedded
      preferencesUrl
      gdprWebhooks {
        customerDeletionUrl
        customerDataRequestUrl
        shopDeletionUrl
      }
      appProxy {
        subPath
        subPathPrefix
        url
      }
      developmentStorePreviewEnabled
      disabledFlags
    }
  }

With variables:
{
  "apiKey": "*****"
}

With request headers:
 - User-Agent: Shopify CLI; v=3.65.3
 - Keep-Alive: timeout=30
 - Sec-CH-UA-PLATFORM: darwin
 - Content-Type: application/json

2024-08-13T20:45:35.659Z: Request to https://partners.shopify.com/api/cli/graphql completed in 88 ms
With response headers:
 - cache-control: max-age=0, private, must-revalidate
 - content-type: application/json; charset=utf-8
 - etag: W/"b1a4c0d269b1a9a93a32e8105871a637"
 - x-request-id: c430c296-69ed-4eee-9568-46af7ce2ae15-1723581935

╭─ error ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                                                                                                        │
│  Couldn't find the app with Client ID `a37713c7a190c925231a282fb793e1dc`                                                                                                               │
│                                                                                                                                                                                        │
│  You can pass `--reset` to your command to reset your app configuration.                                                                                                               │
│                                                                                                                                                                                        │
╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

2024-08-13T20:45:35.676Z: 
Running system process:
  · Command: npm prefix
  · Working directory: /Users/patrick.son/Klaviyo/Repos/atlas/customer-hub-widgets

2024-08-13T20:45:35.811Z: Obtaining the dependency manager in directory /Users/patrick.son/Klaviyo/Repos/atlas/customer-hub-widgets...
2024-08-13T20:45:35.919Z: 
Running system process:
  · Command: ruby -v
  · Working directory: /Users/patrick.son/Klaviyo/Repos/atlas/customer-hub-widgets

2024-08-13T20:45:35.996Z: Request to https://monorail-edge.shopifysvc.com/v1/produce completed in 65 ms
With response headers:
 - x-request-id: e5b33c4d-c82f-4a85-baa8-221b8b7e9085

2024-08-13T20:45:35.997Z: Analytics event sent: {
  "command": "app dev",
  "time_start": 1723581934051,
  "time_end": 1723581935672,
  "total_time": 1621,
  "success": false,
  "cli_version": "3.65.3",
  "ruby_version": "2.6.10",
  "node_version": "20.13.1",
  "is_employee": false,
  "uname": "darwin arm64",
  "env_ci": false,
  "env_plugin_installed_any_custom": false,
  "env_plugin_installed_shopify": "[\"@shopify/cli\"]",
  "env_shell": "zsh",
  "env_device_id": "f21e8ebe51e5e58936877cc31013f4dc5388b5b2",
  "env_cloud": "localhost",
  "env_package_manager": "npm",
  "env_is_global": true,
  "cmd_app_warning_api_key_deprecation_displayed": true,
  "cmd_app_all_configs_any": true,
  "cmd_app_all_configs_clients": "{\"shopify.app.toml\":\"afb7f660ab05585110849d8706a812a4\"}",
  "cmd_app_linked_config_used": true,
  "cmd_app_linked_config_name": "shopify.app.toml",
  "cmd_app_linked_config_git_tracked": true,
  "cmd_app_linked_config_source": "cached",
  "partner_id": 3647805,
  "api_key": "****",
  "cmd_all_timing_network_ms": 1247,
  "cmd_all_timing_prompts_ms": 0,
  "cmd_all_launcher": "unknown",
  "cmd_all_topic": "app",
  "cmd_all_plugin": "@shopify/app",
  "cmd_all_verbose": true,
  "cmd_all_path_override": true,
  "cmd_all_path_override_hash": "e53cdc56a3a5edaac4dd54315399ce917bd07dca",
  "cmd_app_dependency_installation_skipped": false,
  "cmd_app_reset_used": false,
  "cmd_dev_tunnel_type": "cloudflare",
  "cmd_all_timing_active_ms": 373,
  "cmd_all_exit": "expected_error",
  "args": "--verbose",
  "error_message": "Couldn't find the app with Client ID a37713c7a190c925231a282fb793e1dc",
  "env_plugin_installed_all": "[\"@shopify/cli\"]",
  "metadata": "{\"extraPublic\":{},\"extraSensitive\":{}}"
}
2024-08-13T20:45:36.007Z: Reporting handled error to Bugsnag: Couldn't find the app with Client ID a37713c7a190c925231a282fb793e1dc
2024-08-13T20:45:36.356Z: 
Running system process:
  · Command: npm prefix
  · Working directory: /Users/patrick.son/Klaviyo/Repos/atlas/customer-hub-widgets

2024-08-13T20:45:36.457Z: Obtaining the dependency manager in directory /Users/patrick.son/Klaviyo/Repos/atlas/customer-hub-widgets...

Reproduction steps

  1. init a new extension only app
  2. Run shopify app dev
  3. Observe that it doesn't work

Operating System

macOS Sonoma 14.6.1

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

3.65.3

Shell

zsh

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

v20.13.1

What language and version are you using in your application?

No response

amcaplan commented 1 month ago

Hi @patrick-r-son, have you tried running with --reset as the error message suggested?

isaacroldan commented 1 month ago

This is likely happening because you have a environment variable that overrides the client-id: look for SHOPIFY_FLAG_APP_API_KEY or SHOPIFY_FLAG_CLIENT_ID with that value (a37713c7a190c925231a282fb793e1dc)

patrick-r-son commented 1 month ago

@isaacroldan 😅 that was it, this repo has an environment variable we use for the Shopify GraphQL API. I did search for that, but didn't find it yesterday because I had VSCode set to ignore .gitignored files in search.