Shopify / cli

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

[Bug]: CI for Shopify github action to automatically deploy extension fails #2546

Closed Jay-Plumb closed 1 year ago

Jay-Plumb commented 1 year ago

Please confirm that you have:

In which of these areas are you experiencing a problem?

Extension

Expected behavior

For CI/CD I have the following code:

# https://shopify.dev/docs/apps/tools/cli/ci-cd
# https://shopify.dev/docs/apps/tools/cli/ci-cd#step-3-integrate-shopify-cli-into-your-pipeline

name: Deploy Extensions
on:
  push:
    branches:
      - main
  pull_request:

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  deploy:
    name: Deploy
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v1
      - uses: actions/setup-node@v3
        with:
          node-version: 18

      - name: Install npm Dependencies
        run: |
          npm install

      - name: Deploy
        env:
          SHOPIFY_CLI_PARTNERS_TOKEN: ${{ secrets.SHOPIFY_CLI_PARTNERS_TOKEN }}
          # .env content - unique to each app
          SHOPIFY_API_KEY: ${{ secrets.SHOPIFY_API_KEY }}
        run: |
          npm run deploy -- -f --verbose

Both SHOPIFY_CLI_PARTNERS_TOKEN and SHOPIFY_API_KEY are defined as a secret and pulled from the shopify partner dashboard and from the .env file generated.

Actual behavior

Error: No Organization found

Next steps
• Have you created a Shopify Partners organization [1]?
• Have you confirmed your accounts from the emails you received?
• Need to connect to a different App or organization? Run the command
again with --reset
• Do you have access to the right Shopify Partners organization? The CLI

is loading this organization [2]   

[1] https://partners.shopify.com/signup [2] https://partner.shopify.com/116440

Verbose output

> shopify app deploy -f --verbose

2023-07-31T09:32:46.880Z: Running command app deploy
2023-07-31T09:32:46.964Z: Reading cached app information for directory /home/runner/work/ci/ci...
2023-07-31T09:32:46.966Z: Reading the content of file at shopify.app.toml...
2023-07-31T09:32:46.970Z: Reading the content of file at shopify.app.toml...
2023-07-31T09:32:46.977Z: Reading the content of file at shopify.app.toml...
2023-07-31T09:32:47.058Z: Reading the content of file at extensions/ci-extension/shopify.extension.toml...
2023-07-31T09:32:47.062Z: Reading the content of file at extensions/ci-extension/shopify.extension.toml...
2023-07-31T09:32:47.065Z: Reading the content of file at package.json...
2023-07-31T09:32:47.066Z: Reading the content of file at package.json...
2023-07-31T09:32:47.068Z: Obtaining the dependency manager in directory /home/runner/work/ci/ci...
2023-07-31T09:32:47.076Z: Reading the content of file at shopify.web.toml...
2023-07-31T09:32:47.080Z: Reading the content of file at package.json...
2023-07-31T09:32:47.083Z: Ensuring that the user is authenticated with the Partners API with the following scopes:
[]

2023-07-31T09:32:47.085Z: Sending POST request to URL https://accounts.shopify.com/oauth/token?grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Atoken-exchange&requested_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aaccess_token&subject_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aaccess_token&client_id=fbdb2649-e327-4907-8f67-908d24cfd7e3&audience=271e16d403dfa18082ffb3d197bd2b5f4479c3fc32736d69296829cbb28d41a6&scope=https%3A%2F%2Fapi.shopify.com%2Fauth%2Fpartners.app.cli.access&subject_token=***
With request headers:
 - User-Agent: Shopify CLI; v=3.48.0
 - Keep-Alive: timeout=30
 - Sec-CH-UA-PLATFORM: linux
 - Content-Type: application/json

2023-07-31T09:32:47.270Z: Request to https://accounts.shopify.com/oauth/token?grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Atoken-exchange&requested_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aaccess_token&subject_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aaccess_token&client_id=fbdb2649-e327-4907-8f67-908d24cfd7e3&audience=271e16d403dfa18082ffb3d197bd2b5f4479c3fc32736d69296829cbb28d41a6&scope=https%3A%2F%2Fapi.shopify.com%2Fauth%2Fpartners.app.cli.access&subject_token=*** completed in 175 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/"2c65bd4ea4bb7ad609dc2a349fb96592"
 - x-request-id: e88cd08a-c116-41f4-8b21-c8043c84c1ea

2023-07-31T09:32:47.277Z: Sending "Partners" GraphQL request:
  query FindApp($apiKey: String!) {
    app(apiKey: $apiKey) {
      id
      title
      apiKey
      organizationId
      apiSecretKeys {
        secret
      }
      appType
      grantedScopes
      betas {
        unifiedAppDeployment
        unifiedAppDeploymentOptIn
      }
      applicationUrl
      redirectUrlWhitelist
      requestedAccessScopes
      webhookApiVersion
      embedded
      posEmbedded
      preferencesUrl
      gdprWebhooks {
        customerDeletionUrl
        customerDataRequestUrl
        shopDeletionUrl
      }
      appProxy {
        subPath
        subPathPrefix
        url
      }
    }
  }

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

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

2023-07-31T09:32:48.275Z: Request to https://partners.shopify.com/api/cli/graphql completed in 980 ms
With response headers:
 - cache-control: max-age=0, private, must-revalidate
 - content-type: application/json; charset=utf-8
 - etag: W/"2132e77d3f3a42c88a967c7899b5ed1e"
 - x-request-id: 7a7c79ae-1df3-458b-a55b-bbdd0d01a4b6

2023-07-31T09:32:48.275Z: Sending "Partners" GraphQL request:
  query FindOrganization($id: ID!) {
    organizations(id: $id, first: 1) {
      nodes {
        id
        businessName
        website
      }
    }
  }

With variables:
{
  "id": "116440"
}

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

2023-07-31T09:32:48.525Z: Request to https://partners.shopify.com/api/cli/graphql completed in 246 ms
With response headers:
 - cache-control: max-age=0, private, must-revalidate
 - content-type: application/json; charset=utf-8
 - etag: W/"d984c4fd2e64e933dc657c6f3ef428c1"
 - x-request-id: 43467434-f68b-4b70-91eb-ef4cab66db62

╭─ error ──────────────────────────────────────────────────────────────────────╮
│                                                                              │
│  No Organization found                                                       │
│                                                                              │
│  Next steps                                                                  │
│    • Have you created a Shopify Partners organization [1]?                   │
│    • Have you confirmed your accounts from the emails you received?          │
│    • Need to connect to a different App or organization? Run the command     │
│      again with `--reset`                                                    │
│    • Do you have access to the right Shopify Partners organization? The CLI  │
│      is loading this organization [2]                                        │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯
[1] https://partners.shopify.com/signup
[2] https://partner.shopify.com/116440

2023-07-31T09:32:48.608Z: Obtaining the dependency manager in directory /home/runner/work/ci/ci...
2023-07-31T09:32:48.622Z: 
Running system process:
  · Command: ruby -v
  · Working directory: /home/runner/work/ci/ci

2023-07-31T09:32:48.629Z: Obtaining the dependency manager in directory /home/runner/work/ci/ci...
2023-07-31T09:32:48.651Z: 
Running system process:
  · Command: ruby -v
  · Working directory: /home/runner/work/ci/ci

2023-07-31T09:32:48.816Z: Request to https://monorail-edge.shopifysvc.com/v1/produce completed in 138 ms
With response headers:
 - x-request-id: 22bc6a18-08bb-4105-b515-09495cfb58be

2023-07-31T09:32:48.819Z: Analytics event sent: {
  "command": "app deploy",
  "time_start": 1690795966881,
  "time_end": 1690795968627,
  "total_time": 1746,
  "success": true,
  "cli_version": "3.48.0",
  "ruby_version": "3.0.2",
  "node_version": "18.17.0",
  "is_employee": false,
  "uname": "linux amd64",
  "env_ci": true,
  "env_ci_platform": "github",
  "env_plugin_installed_any_custom": false,
  "env_plugin_installed_shopify": "[\"@shopify/app\",\"@shopify/cli\",\"@shopify/plugin-cloudflare\",\"@shopify/plugin-did-you-mean\"]",
  "env_shell": "bash",
  "env_device_id": "55e81496e073a0f4b31c2cdc4cfd281afeac4857",
  "env_cloud": "localhost",
  "env_package_manager": "npm",
  "cmd_app_warning_api_key_deprecation_displayed": false,
  "cmd_deploy_flag_message_used": false,
  "cmd_deploy_flag_version_used": false,
  "cmd_deploy_flag_source_url_used": false,
  "project_type": "node",
  "app_extensions_any": true,
  "app_extensions_breakdown": "{\"ui_extension\":1}",
  "app_extensions_count": 1,
  "app_extensions_custom_layout": false,
  "app_extensions_function_any": false,
  "app_extensions_function_count": 0,
  "app_extensions_theme_any": false,
  "app_extensions_theme_count": 0,
  "app_extensions_ui_any": true,
  "app_extensions_ui_count": 1,
  "app_name_hash": "01aa46074612a14e99144db22d6c0fe70f61f8d3",
  "app_path_hash": "3d1d98f2b4d09b6866bb21d532e9d616e2fd7295",
  "app_scopes": "[\"write_products\"]",
  "app_web_backend_any": true,
  "app_web_backend_count": 1,
  "app_web_custom_layout": true,
  "app_web_framework": "remix",
  "app_web_frontend_any": true,
  "app_web_frontend_count": 1,
  "env_package_manager_workspaces": true,
  "cmd_app_all_configs_any": true,
  "cmd_app_all_configs_clients": "{\"shopify.app.toml\":\"***\"}",
  "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": "default",
  "cmd_app_linked_config_uses_cli_managed_urls": true,
  "cmd_all_launcher": "npm",
  "cmd_all_topic": "app",
  "cmd_all_plugin": "@shopify/app",
  "cmd_all_verbose": true,
  "cmd_all_path_override": true,
  "cmd_all_path_override_hash": "3d1d98f2b4d09b6866bb21d532e9d616e2fd7295",
  "cmd_app_reset_used": false,
  "args": "-f --verbose",
  "app_name": "ci-ui-extensions",
  "env_plugin_installed_all": "[\"@shopify/app\",\"@shopify/cli\",\"@shopify/plugin-cloudflare\",\"@shopify/plugin-did-you-mean\"]",
  "metadata": "{\"extraPublic\":{},\"extraSensitive\":{}}"
}
2023-07-31T09:32:48.820Z: Completed command app deploy
2023-07-31T09:32:48.824Z: Request to https://monorail-edge.shopifysvc.com/v1/produce completed in 150 ms
With response headers:
 - x-request-id: abe53697-4716-46e7-9bab-ec057976e8af

2023-07-31T09:32:48.825Z: Analytics event sent: {
  "command": "app deploy",
  "time_start": 1690795966881,
  "time_end": 1690795968598,
  "total_time": 1717,
  "success": false,
  "cli_version": "3.48.0",
  "ruby_version": "3.0.2",
  "node_version": "18.17.0",
  "is_employee": false,
  "uname": "linux amd64",
  "env_ci": true,
  "env_ci_platform": "github",
  "env_plugin_installed_any_custom": false,
  "env_plugin_installed_shopify": "[\"@shopify/app\",\"@shopify/cli\",\"@shopify/plugin-cloudflare\",\"@shopify/plugin-did-you-mean\"]",
  "env_shell": "bash",
  "env_device_id": "55e81496e073a0f4b31c2cdc4cfd281afeac4857",
  "env_cloud": "localhost",
  "env_package_manager": "npm",
  "cmd_app_warning_api_key_deprecation_displayed": false,
  "cmd_deploy_flag_message_used": false,
  "cmd_deploy_flag_version_used": false,
  "cmd_deploy_flag_source_url_used": false,
  "project_type": "node",
  "app_extensions_any": true,
  "app_extensions_breakdown": "{\"ui_extension\":1}",
  "app_extensions_count": 1,
  "app_extensions_custom_layout": false,
  "app_extensions_function_any": false,
  "app_extensions_function_count": 0,
  "app_extensions_theme_any": false,
  "app_extensions_theme_count": 0,
  "app_extensions_ui_any": true,
  "app_extensions_ui_count": 1,
  "app_name_hash": "01aa46074612a14e99144db22d6c0fe70f61f8d3",
  "app_path_hash": "3d1d98f2b4d09b6866bb21d532e9d616e2fd7295",
  "app_scopes": "[\"write_products\"]",
  "app_web_backend_any": true,
  "app_web_backend_count": 1,
  "app_web_custom_layout": true,
  "app_web_framework": "remix",
  "app_web_frontend_any": true,
  "app_web_frontend_count": 1,
  "env_package_manager_workspaces": true,
  "cmd_app_all_configs_any": true,
  "cmd_app_all_configs_clients": "{\"shopify.app.toml\":\"***\"}",
  "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": "default",
  "cmd_app_linked_config_uses_cli_managed_urls": true,
  "cmd_all_launcher": "npm",
  "cmd_all_topic": "app",
  "cmd_all_plugin": "@shopify/app",
  "cmd_all_verbose": true,
  "cmd_all_path_override": true,
  "cmd_all_path_override_hash": "3d1d98f2b4d09b6866bb21d532e9d616e2fd7295",
  "cmd_app_reset_used": false,
  "args": "-f --verbose",
  "error_message": "No Organization found",
  "app_name": "ci-ui-extensions",
  "env_plugin_installed_all": "[\"@shopify/app\",\"@shopify/cli\",\"@shopify/plugin-cloudflare\",\"@shopify/plugin-did-you-mean\"]",
  "metadata": "{\"extraPublic\":{},\"extraSensitive\":{}}"
}
Error: Process completed with exit code 1.

Reproduction steps

  1. Go through https://shopify.dev/docs/apps/tools/cli/ci-cd#step-3-integrate-shopify-cli-into-your-pipeline and the demo code also gives the same error

Operating System

Ubuntu 22.04.2 LTS

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

"@shopify/cli": "3.48.0", "@shopify/app": "3.48.0",

Shell

No response

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

v18

What language and version are you using in your application?

"@remix-run/node": "^1.19.1"

Arkham commented 1 year ago

hey @Jay-Plumb have you tried to deploy once manually from your machine? I believe the first deploy cannot be done on the CI/CD instance.

Jay-Plumb commented 1 year ago

Hey @Arkham, I did perform a manual deploy locally using npm run deploy -- -f which shows the deployments automatically versioning:

Screenshot 2023-07-31 at 19 20 59
Arkham commented 1 year ago

great! so what happens if you run these commands locally?

npm run shopify auth logout
SHOPIFY_CLI_PARTNERS_TOKEN=your_token SHOPIFY_API_KEY=your_key npm run deploy
Jay-Plumb commented 1 year ago

@Arkham Running the above commands locally I see the same error as shown in the github action:

> shopify app deploy

  No Organization found                                                                            

Next steps                                                                                       
  • Have you created a Shopify Partners organization?                                            
  • Have you confirmed your accounts from the emails you received?                               
  • Need to connect to a different App or organization? Run the command again with `--reset`     
  • Do you have access to the right Shopify Partners organization? The CLI is loading this       
      organization                                                                                 

The CLI is loading "this organization" does point to the correct organisation that contains the UI app extension and the generated SHOPIFY_CLI_PARTNERS_TOKEN

dev-prakhar commented 1 year ago

@Arkham

I think there might be some issues with the permissions. I was facing the same issue.

But if we generate a token with "Functions" access, I'm able to deploy the extensions. I am not able to deploy the extensions with just "UI Extensions" access. CleanShot 2023-08-01 at 16 17 12@2x

For now, I have generated a token with "UI Extension" access and "Functions" access.

Arkham commented 1 year ago

hey @dev-prakhar really good find, I was about to recommend that generating a new token with both extensions and functions support should work. I'm still investigating why having only extensions is not working.

Jay-Plumb commented 1 year ago

@dev-prakhar @Arkham Thanks both. The token was generated without the function checked so for now I will generate a new token with both checked for a temp solution

Jay-Plumb commented 1 year ago

@Arkham Just ran the following command locally with the new SHOPIFY_CLI_PARTNERS_TOKEN generated with both UI Extensions and Functions checked:

npm run shopify auth logout
SHOPIFY_CLI_PARTNERS_TOKEN=your_token SHOPIFY_API_KEY=your_key npm run deploy

The following error is different from previous:

                                                                                                  │
│  request to https://accounts.shopify.com/oauth/token?grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agr  │
│  ant-type%3Atoken-exchange&requested_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aacces  │
│  s_token&subject_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aaccess_token&client_id=fb  │
│  db2649-e327-4907-8f67-908d24cfd7e3&audience=271e16d403dfa18082ffb3d197bd2b5f4479c3fc32736d69296  │
│  829cbb28d41a6&scope=https%3A%2F%2Fapi.shopify.com%2Fauth%2Fpartners.app.cli.access&subject_toke  │
│  n=xx failed, reason:          │
│  getaddrinfo ENOTFOUND accounts.shopify.com     
Arkham commented 1 year ago

that seems to be a DNS issue, can you try opening https://accounts.shopify.com/ in your browser, restarting your network, etc?

Jay-Plumb commented 1 year ago

yeah looks like a few sites are down in Asia ATM. I'll give it another try tomorrow morning. Thanks!

Arkham commented 1 year ago

This should be fixed, so that a partners token that only has extensions permissions works. Thanks for reporting and providing workarounds folks!

Jay-Plumb commented 1 year ago

@Arkham still not working for me. Here is the latest error:

╭─ error ──────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                          │
│                                                                                                          │
│  To investigate the issue, examine this stack trace:                                                     │
│    at tokenRequestErrorHandler (@shopify/cli-kit/src/private/node/session/exchange.ts:174)               │
│      return new InvalidRequestError()                                                                    │
│    at mapError (@shopify/cli-kit/src/public/node/result.ts:142)                                          │
│      return err(mapper(this.error))                                                                      │
│    at requestAppToken (@shopify/cli-kit/src/private/node/session/exchange.ts:153)                        │
│      const value = tokenResult.mapError(tokenRequestErrorHandler).valueOrBug()                           │
│    at processTicksAndRejections (node:internal/process/task_queues:95)                                   │
│    at async exchangeCustomPartnerToken (@shopify/cli-kit/src/private/node/session/exchange.ts:92)        │
│      const newToken = await requestAppToken('partners', token,                                           │
│      ['https://api.shopify.com/auth/partners.app.cli.access'])                                           │
│    at async ensureAuthenticatedPartners (@shopify/cli-kit/src/public/node/session.ts:32)                 │
│      return (await exchangeCustomPartnerToken(envToken)).accessToken                                     │
│    at async ensureDeployContext (@shopify/app/src/cli/services/context.ts:317)                           │
│      const token = await ensureAuthenticatedPartners()                                                   │
│    at async deploy (@shopify/app/src/cli/services/deploy.ts:64)                                          │
│      let {app, identifiers, partnersApp, token, deploymentMode} = await ensureDeployContext(options)     │
│    at run (@shopify/app/src/cli/commands/app/deploy.ts:95)                                               │
│      await deploy({                                                                                      │
│                        
Jay-Plumb commented 1 year ago

@Arkham here is the full stack trace:

Command ran locally:

SHOPIFY_CLI_PARTNERS_TOKEN=xxx SHOPIFY_API_KEY=xxx npm run deploy -- -f --verbose

Stack Trace

> shopify app deploy -f --verbose

2023-08-02T01:05:46.227Z: Running command app deploy
2023-08-02T01:05:46.301Z: Reading cached app information for directory /Users/jasonplumb/pixelcabin/extensions/ci-cd-extension...
2023-08-02T01:05:46.303Z: Reading the content of file at shopify.app.toml...
2023-08-02T01:05:46.307Z: Reading the content of file at shopify.app.toml...
2023-08-02T01:05:46.318Z: Reading the content of file at shopify.app.toml...
2023-08-02T01:05:46.386Z: Reading the .env file at .env
2023-08-02T01:05:46.387Z: Reading the content of file at .env...
2023-08-02T01:05:46.392Z: Reading the content of file at extensions/checkout-ui-banner/shopify.extension.toml...
2023-08-02T01:05:46.397Z: Reading the content of file at extensions/checkout-ui-banner/shopify.extension.toml...
2023-08-02T01:05:46.404Z: Reading the content of file at package.json...
2023-08-02T01:05:46.406Z: Reading the content of file at package.json...
2023-08-02T01:05:46.408Z: Obtaining the dependency manager in directory /Users/jasonplumb/pixelcabin/extensions/ci-cd-extension...
2023-08-02T01:05:46.425Z: Reading the content of file at package.json...
2023-08-02T01:05:46.426Z: Unable to decide project type as no web backend
2023-08-02T01:05:46.429Z: Ensuring that the user is authenticated with the Partners API with the following scopes:
[]

2023-08-02T01:05:46.432Z: Sending POST request to URL https://accounts.shopify.com/oauth/token?grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Atoken-exchange&requested_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aaccess_token&subject_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aaccess_token&client_id=fbdb2649-e327-4907-8f67-908d24cfd7e3&audience=271e16d403dfa18082ffb3d197bd2b5f4479c3fc32736d69296829cbb28d41a6&scope=https%3A%2F%2Fapi.shopify.com%2Fauth%2Fpartners.app.cli.access&subject_token=xxx
With request headers:
 - User-Agent: Shopify CLI; v=3.48.0
 - Keep-Alive: timeout=30
 - Sec-CH-UA-PLATFORM: darwin
 - Content-Type: application/json

2023-08-02T01:05:46.766Z: Request to https://accounts.shopify.com/oauth/token?grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Atoken-exchange&requested_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aaccess_token&subject_token_type=urn%3Aietf%3Aparams%3Aoauth%3Atoken-type%3Aaccess_token&client_id=fbdb2649-e327-4907-8f67-908d24cfd7e3&audience=271e16d403dfa18082ffb3d197bd2b5f4479c3fc32736d69296829cbb28d41a6&scope=https%3A%2F%2Fapi.shopify.com%2Fauth%2Fpartners.app.cli.access&subject_token=xxx completed in 325 ms
With response headers:
 - cache-control: no-cache, no-store, private, must-revalidate, max-age=0
 - content-type: application/json; charset=utf-8
 - x-request-id: d52d629f-8906-4036-9696-d6f253aff4a0

╭─ error ──────────────────────────────────────────────────────────────────────────────────────────────────╮
│                                                                                                          │
│                                                                                                          │
│  To investigate the issue, examine this stack trace:                                                     │
│    at tokenRequestErrorHandler (@shopify/cli-kit/src/private/node/session/exchange.ts:174)               │
│      return new InvalidRequestError()                                                                    │
│    at mapError (@shopify/cli-kit/src/public/node/result.ts:142)                                          │
│      return err(mapper(this.error))                                                                      │
│    at requestAppToken (@shopify/cli-kit/src/private/node/session/exchange.ts:153)                        │
│      const value = tokenResult.mapError(tokenRequestErrorHandler).valueOrBug()                           │
│    at processTicksAndRejections (node:internal/process/task_queues:95)                                   │
│    at async exchangeCustomPartnerToken (@shopify/cli-kit/src/private/node/session/exchange.ts:92)        │
│      const newToken = await requestAppToken('partners', token,                                           │
│      ['https://api.shopify.com/auth/partners.app.cli.access'])                                           │
│    at async ensureAuthenticatedPartners (@shopify/cli-kit/src/public/node/session.ts:32)                 │
│      return (await exchangeCustomPartnerToken(envToken)).accessToken                                     │
│    at async ensureDeployContext (@shopify/app/src/cli/services/context.ts:317)                           │
│      const token = await ensureAuthenticatedPartners()                                                   │
│    at async deploy (@shopify/app/src/cli/services/deploy.ts:64)                                          │
│      let {app, identifiers, partnersApp, token, deploymentMode} = await ensureDeployContext(options)     │
│    at run (@shopify/app/src/cli/commands/app/deploy.ts:95)                                               │
│      await deploy({                                                                                      │
│                                                                                                          │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────╯

2023-08-02T01:05:46.934Z: Obtaining the dependency manager in directory /Users/jasonplumb/pixelcabin/extensions/ci-cd-extension...
2023-08-02T01:05:46.939Z: 
Running system process:
  · Command: ruby -v
  · Working directory: /Users/jasonplumb/pixelcabin/extensions/ci-cd-extension

2023-08-02T01:05:46.945Z: Obtaining the dependency manager in directory /Users/jasonplumb/pixelcabin/extensions/ci-cd-extension...
2023-08-02T01:05:46.955Z: 
Running system process:
  · Command: ruby -v
  · Working directory: /Users/jasonplumb/pixelcabin/extensions/ci-cd-extension

2023-08-02T01:05:47.277Z: Request to https://monorail-edge.shopifysvc.com/v1/produce completed in 312 ms
With response headers:
 - x-request-id: 0f8ca415-f9d0-4999-b830-f5d1f725c490

2023-08-02T01:05:47.281Z: Analytics event sent: {
  "command": "app deploy",
  "time_start": 1690938346228,
  "time_end": 1690938346942,
  "total_time": 714,
  "success": true,
  "cli_version": "3.48.0",
  "ruby_version": "3.0.5",
  "node_version": "18.15.0",
  "is_employee": false,
  "uname": "darwin amd64",
  "env_ci": false,
  "env_plugin_installed_any_custom": false,
  "env_plugin_installed_shopify": "[\"@shopify/app\",\"@shopify/cli\",\"@shopify/plugin-cloudflare\",\"@shopify/plugin-did-you-mean\"]",
  "env_shell": "zsh",
  "env_device_id": "7f3fc8d3985013f0dc47382561e3d8c0fcbe5aa1",
  "env_cloud": "localhost",
  "env_package_manager": "npm",
  "cmd_app_warning_api_key_deprecation_displayed": false,
  "cmd_deploy_flag_message_used": false,
  "cmd_deploy_flag_version_used": false,
  "cmd_deploy_flag_source_url_used": false,
  "app_extensions_any": true,
  "app_extensions_breakdown": "{\"ui_extension\":1}",
  "app_extensions_count": 1,
  "app_extensions_custom_layout": false,
  "app_extensions_function_any": false,
  "app_extensions_function_count": 0,
  "app_extensions_theme_any": false,
  "app_extensions_theme_count": 0,
  "app_extensions_ui_any": true,
  "app_extensions_ui_count": 1,
  "app_name_hash": "8e5e0e67d3b72bc4b70bd681afb27c180806f93e",
  "app_path_hash": "5d95bc5b6ac8050c016d2c41eeb8deb15152a8e7",
  "app_scopes": "[\"write_products\"]",
  "app_web_backend_any": false,
  "app_web_backend_count": 0,
  "app_web_custom_layout": false,
  "app_web_frontend_any": false,
  "app_web_frontend_count": 0,
  "env_package_manager_workspaces": true,
  "cmd_app_all_configs_any": true,
  "cmd_app_all_configs_clients": "{\"shopify.app.toml\":\"xxx\"}",
  "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",
  "cmd_all_launcher": "npm",
  "cmd_all_topic": "app",
  "cmd_all_plugin": "@shopify/app",
  "cmd_all_verbose": true,
  "cmd_all_path_override": true,
  "cmd_all_path_override_hash": "5d95bc5b6ac8050c016d2c41eeb8deb15152a8e7",
  "cmd_app_reset_used": false,
  "args": "-f --verbose",
  "app_name": "ci-cd-extension",
  "env_plugin_installed_all": "[\"@shopify/app\",\"@shopify/cli\",\"@shopify/plugin-cloudflare\",\"@shopify/plugin-did-you-mean\"]",
  "metadata": "{\"extraPublic\":{},\"extraSensitive\":{}}"
}
2023-08-02T01:05:47.283Z: Completed command app deploy
2023-08-02T01:05:47.293Z: Request to https://monorail-edge.shopifysvc.com/v1/produce completed in 342 ms
With response headers:
 - x-request-id: 194ef86e-563d-4932-a5e8-ca6d08629005

2023-08-02T01:05:47.296Z: Analytics event sent: {
  "command": "app deploy",
  "time_start": 1690938346228,
  "time_end": 1690938346917,
  "total_time": 689,
  "success": false,
  "cli_version": "3.48.0",
  "ruby_version": "3.0.5",
  "node_version": "18.15.0",
  "is_employee": false,
  "uname": "darwin amd64",
  "env_ci": false,
  "env_plugin_installed_any_custom": false,
  "env_plugin_installed_shopify": "[\"@shopify/app\",\"@shopify/cli\",\"@shopify/plugin-cloudflare\",\"@shopify/plugin-did-you-mean\"]",
  "env_shell": "zsh",
  "env_device_id": "7f3fc8d3985013f0dc47382561e3d8c0fcbe5aa1",
  "env_cloud": "localhost",
  "env_package_manager": "npm",
  "cmd_app_warning_api_key_deprecation_displayed": false,
  "cmd_deploy_flag_message_used": false,
  "cmd_deploy_flag_version_used": false,
  "cmd_deploy_flag_source_url_used": false,
  "app_extensions_any": true,
  "app_extensions_breakdown": "{\"ui_extension\":1}",
  "app_extensions_count": 1,
  "app_extensions_custom_layout": false,
  "app_extensions_function_any": false,
  "app_extensions_function_count": 0,
  "app_extensions_theme_any": false,
  "app_extensions_theme_count": 0,
  "app_extensions_ui_any": true,
  "app_extensions_ui_count": 1,
  "app_name_hash": "8e5e0e67d3b72bc4b70bd681afb27c180806f93e",
  "app_path_hash": "5d95bc5b6ac8050c016d2c41eeb8deb15152a8e7",
  "app_scopes": "[\"write_products\"]",
  "app_web_backend_any": false,
  "app_web_backend_count": 0,
  "app_web_custom_layout": false,
  "app_web_frontend_any": false,
  "app_web_frontend_count": 0,
  "env_package_manager_workspaces": true,
  "cmd_app_all_configs_any": true,
  "cmd_app_all_configs_clients": "{\"shopify.app.toml\":\"xxx\"}",
  "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",
  "cmd_all_launcher": "npm",
  "cmd_all_topic": "app",
  "cmd_all_plugin": "@shopify/app",
  "cmd_all_verbose": true,
  "cmd_all_path_override": true,
  "cmd_all_path_override_hash": "5d95bc5b6ac8050c016d2c41eeb8deb15152a8e7",
  "cmd_app_reset_used": false,
  "args": "-f --verbose",
  "error_message": "",
  "app_name": "ci-cd-extension",
  "env_plugin_installed_all": "[\"@shopify/app\",\"@shopify/cli\",\"@shopify/plugin-cloudflare\",\"@shopify/plugin-did-you-mean\"]",
  "metadata": "{\"extraPublic\":{},\"extraSensitive\":{}}"
}
2023-08-02T01:05:47.343Z: Obtaining the dependency manager in directory /Users/jasonplumb/pixelcabin/extensions/ci-cd-extension...
Arkham commented 1 year ago

the token seems invalid, can you try generating a new one?

Jay-Plumb commented 1 year ago

@Arkham the token was valid and had both Function and ui extensions checked. I have since created a new token with just UI extension checked and all works now. Thanks for the help all!

Arkham commented 1 year ago

maybe it was because the CLI caches some authentication token to avoid making unnecessary requests, and the cached value had become invalid? having a token with both extensions and functions should work just as well (I just tested it) :)

Jay-Plumb commented 1 year ago

@Arkham that would make sense. Thanks for testing all cases on your end