Shopify / cli

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

[Bug]: Shopify CLI 3.65.0 does not reliably detect app ID is valid in --force mode, breaks CI pipelines #4264

Closed jhardin-accumula closed 2 weeks ago

jhardin-accumula commented 1 month ago

Please confirm that you have:

In which of these areas are you experiencing a problem?

App

Expected behavior

Executing npm run shopify app deploy --force in a CI Dockerfile build script with a valid, known-to-Shopify app ID in the TOML file and in $SHOPIFY_API_KEY and a valid Partner token in $SHOPIFY_CLI_PARTNERS_TOKEN should detect that the app is known to Shopify and should successfully deploy the changes and register a new version of the app.

#23 5.384     
#23 5.473 ╭─ info ───────────────────────────────────────────────────────────────────────╮
#23 5.473 │                                                                              │
#23 5.473 │  Using shopify.app.toml:                                                     │
#23 5.473 │                                                                              │
#23 5.473 │    • Org:             Accumula Labs, Inc.                                    │
#23 5.473 │    • App:             Mortar App Test                                        │
#23 5.473 │    • Include config:  Yes                                                    │
#23 5.473 │                                                                              │
#23 5.473 │   You can pass `--reset` to your command to reset your app configuration.    │
#23 5.473 │                                                                              │
#23 5.473 ╰──────────────────────────────────────────────────────────────────────────────╯
#23 5.473 
...
#23 8.331 Releasing an app version ...
#23 8.333 
#23 8.340 ╭─ success ────────────────────────────────────────────────────────────────────╮
#23 8.340 │                                                                              │
#23 8.340 │  New version released to users.                                              │
#23 8.340 │                                                                              │
#23 8.340 │  mortar-app-test-77 [1]                                                      │
#23 8.340 │                                                                              │
#23 8.340 ╰──────────────────────────────────────────────────────────────────────────────╯

This is using CLI 3.64.1

Actual behavior

Build step: npm run shopify -- app deploy --force --verbose --source-control-url "https://bitbucket.org/mumble"; emits:

#24 4.088 Before proceeding, your project needs to be associated with an app.
#24 4.088 
#24 4.140 ╭─ error ──────────────────────────────────────────────────────────────────────╮
#24 4.140 │                                                                              │
#24 4.140 │  Failed to prompt:                                                           │
#24 4.140 │                                                                              │
#24 4.140 │  Create this project as a new app on Shopify?                                │
#24 4.140 │                                                                              │
#24 4.140 │  This usually happens when running a command non-interactively, for example  │
#24 4.140 │   in a CI environment, or when piping input from another process.            │
#24 4.140 │                                                                              │
#24 4.140 │  To resolve this, specify the option in the command, or run the command in   │
#24 4.140 │  an interactive environment such as your local terminal.                     │
#24 4.140 │                                                                              │
#24 4.140 ╰──────────────────────────────────────────────────────────────────────────────╯

...and fails, terminating the CI build.

Installing Shopify CLI 3.64.1 explicitly with no other changes restored the build process to successful completion.

Verbose output

#21 0.496 
#21 0.496 > mortar-cli@1.0.0 shopify
#21 0.496 > shopify app deploy --force --verbose --source-control-url https://bitbucket.org/mumble
#21 0.496 
#21 2.353 2024-08-02T22:31:13.210Z: Running command app deploy
#21 2.377 2024-08-02T22:31:13.235Z: Reading cached app information for directory /var/www/html...
#21 2.378 2024-08-02T22:31:13.236Z: Reading the content of file at shopify.app.toml...
#21 2.383 2024-08-02T22:31:13.241Z: Reading the content of file at shopify.app.toml...
#21 2.411 2024-08-02T22:31:13.269Z: Reading the content of file at package.json...
#21 2.411 2024-08-02T22:31:13.270Z: Reading the content of file at package.json...
#21 2.416 2024-08-02T22:31:13.274Z: 
#21 2.416 Running system process:
#21 2.416   · Command: npm prefix
#21 2.416   · Working directory: /var/www/html
#21 2.416 
#21 2.562 2024-08-02T22:31:13.420Z: Obtaining the dependency manager in directory /var/www/html...
#21 2.787 2024-08-02T22:31:13.645Z: Reading the content of file at web/shopify.web.toml...
#21 2.787 2024-08-02T22:31:13.646Z: Reading the content of file at web/frontend/shopify.web.toml...
#21 2.793 2024-08-02T22:31:13.651Z: Reading the content of file at package.json...
#21 2.797 2024-08-02T22:31:13.655Z: Reading cached app information for directory /var/www/html...
#21 2.799 2024-08-02T22:31:13.657Z: Reading cached app information for directory /var/www/html...
#21 2.799 2024-08-02T22:31:13.657Z: Reading the content of file at shopify.app.toml...
#21 2.800 2024-08-02T22:31:13.658Z: Reading the content of file at shopify.app.toml...
#21 2.809 2024-08-02T22:31:13.667Z: Reading cached app information for directory /var/www/html...
#21 2.809 2024-08-02T22:31:13.667Z: Reading the content of file at shopify.app.toml...
#21 2.810 2024-08-02T22:31:13.668Z: Reading the content of file at shopify.app.toml...
#21 2.819 2024-08-02T22:31:13.677Z: Reading the content of file at package.json...
#21 2.819 2024-08-02T22:31:13.677Z: Reading the content of file at package.json...
#21 2.822 2024-08-02T22:31:13.680Z: 
#21 2.822 Running system process:
#21 2.822   · Command: npm prefix
#21 2.822   · Working directory: /var/www/html
#21 2.822 
#21 2.960 2024-08-02T22:31:13.819Z: Obtaining the dependency manager in directory /var/www/html...
#21 3.019 2024-08-02T22:31:13.878Z: Reading the content of file at web/shopify.web.toml...
#21 3.019 2024-08-02T22:31:13.878Z: Reading the content of file at web/frontend/shopify.web.toml...
#21 3.022 2024-08-02T22:31:13.881Z: Reading the content of file at package.json...
#21 3.024 2024-08-02T22:31:13.883Z: Ensuring that the user is authenticated with the Partners API with the following scopes:
#21 3.024 []
#21 3.024 
#21 3.026 2024-08-02T22:31:13.885Z: 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-XXXX-XXXX-XXXX-908d24cfd7e3&audience=271e16d403dfa18082fXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX829cbb28d41a6&scope=https%3A%2F%2Fapi.shopify.com%2Fauth%2Fpartners.app.cli.access&subject_token=****
#21 3.026 With request headers:
#21 3.026  - User-Agent: Shopify CLI; v=3.65.0
#21 3.026  - Keep-Alive: timeout=30
#21 3.026  - Sec-CH-UA-PLATFORM: linux
#21 3.026  - Content-Type: application/json
#21 3.026 
#21 3.129 2024-08-02T22:31:13.987Z: 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-XXXX-XXXX-XXXX-908d24cfd7e3&audience=271e16d403dfa18082fXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX829cbb28d41a6&scope=https%3A%2F%2Fapi.shopify.com%2Fauth%2Fpartners.app.cli.access&subject_token=**** completed in 87 ms
#21 3.129 With response headers:
#21 3.129  - cache-control: no-cache, no-store, private, must-revalidate, max-age=0
#21 3.129  - content-type: application/json; charset=utf-8
#21 3.129  - etag: W/"399312ee57ef49b2b3e39cb019c09cbf"
#21 3.129  - x-request-id: dadb3d86-5cc2-4178-a54b-505a16e7e260-1722637873
#21 3.129     
#21 3.139 2024-08-02T22:31:13.997Z: Sending "Partners" GraphQL request:
#21 3.139   query currentAccountInfo {
#21 3.139     currentAccountInfo {
#21 3.139       __typename
#21 3.139       ... on ServiceAccount {
#21 3.139         orgName
#21 3.139       }
#21 3.139       ... on UserAccount {
#21 3.139         email
#21 3.139       }
#21 3.139     }
#21 3.139   }
#21 3.139 
#21 3.139 With request headers:
#21 3.139  - User-Agent: Shopify CLI; v=3.65.0
#21 3.139  - Keep-Alive: timeout=30
#21 3.139  - Sec-CH-UA-PLATFORM: linux
#21 3.139  - Content-Type: application/json
#21 3.139 
#21 3.291 2024-08-02T22:31:14.149Z: Request to https://partners.shopify.com/api/cli/graphql completed in 132 ms
#21 3.291 With response headers:
#21 3.291  - cache-control: max-age=0, private, must-revalidate
#21 3.291  - content-type: application/json; charset=utf-8
#21 3.291  - etag: W/"7eb8f76ac991c324b743dc3857f954c7"
#21 3.291  - x-request-id: 77118542-112b-447a-9a6a-127efaff52f5-1722637874
#21 3.291     
#21 3.298 2024-08-02T22:31:14.157Z: Sending "Partners" GraphQL request:
#21 3.298   query AllOrgs {
#21 3.298   organizations(first: 200) {
#21 3.298     nodes {
#21 3.298       id
#21 3.298       businessName
#21 3.298       __typename
#21 3.298     }
#21 3.298     __typename
#21 3.298   }
#21 3.298 }
#21 3.298 
#21 3.298 With request headers:
#21 3.298  - User-Agent: Shopify CLI; v=3.65.0
#21 3.298  - Keep-Alive: timeout=30
#21 3.298  - Sec-CH-UA-PLATFORM: linux
#21 3.298  - Content-Type: application/json
#21 3.298 
#21 3.370 2024-08-02T22:31:14.229Z: Request to https://partners.shopify.com/api/cli/graphql completed in 69 ms
#21 3.370 With response headers:
#21 3.370  - cache-control: max-age=0, private, must-revalidate
#21 3.370  - content-type: application/json; charset=utf-8
#21 3.370  - etag: W/"c1bf1470350e0277ddfcf3b52d962784"
#21 3.370  - x-request-id: 9287e2f2-40d7-4324-9dd5-446ec93a92c1-1722637874
#21 3.370     
#21 3.371 2024-08-02T22:31:14.230Z: Ensuring that the user is authenticated with the Partners API with the following scopes:
#21 3.371 []
#21 3.371 
#21 3.372 2024-08-02T22:31:14.230Z: 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-XXXX-XXXX-XXXX-908d24cfd7e3&audience=271e16d403dfa18082fXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX829cbb28d41a6&scope=https%3A%2F%2Fapi.shopify.com%2Fauth%2Fpartners.app.cli.access&subject_token=****
#21 3.372 With request headers:
#21 3.372  - User-Agent: Shopify CLI; v=3.65.0
#21 3.372  - Keep-Alive: timeout=30
#21 3.372  - Sec-CH-UA-PLATFORM: linux
#21 3.372  - Content-Type: application/json
#21 3.372 
#21 3.488 2024-08-02T22:31:14.346Z: 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-XXXX-XXXX-XXXX-908d24cfd7e3&audience=271e16d403dfa18082fXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX829cbb28d41a6&scope=https%3A%2F%2Fapi.shopify.com%2Fauth%2Fpartners.app.cli.access&subject_token=**** completed in 114 ms
#21 3.488 With response headers:
#21 3.488  - cache-control: no-cache, no-store, private, must-revalidate, max-age=0
#21 3.488  - content-type: application/json; charset=utf-8
#21 3.488  - etag: W/"fe0718c42b90174860e7465f509ab6be"
#21 3.488  - x-request-id: e6263320-81cd-471b-b5cd-4c53416c69c8-1722637874
#21 3.488     
#21 3.493 2024-08-02T22:31:14.351Z: Sending "Partners" GraphQL request:
#21 3.493   query currentAccountInfo {
#21 3.493     currentAccountInfo {
#21 3.493       __typename
#21 3.493       ... on ServiceAccount {
#21 3.493         orgName
#21 3.493       }
#21 3.493       ... on UserAccount {
#21 3.493         email
#21 3.493       }
#21 3.493     }
#21 3.493   }
#21 3.493 
#21 3.493 With request headers:
#21 3.493  - User-Agent: Shopify CLI; v=3.65.0
#21 3.493  - Keep-Alive: timeout=30
#21 3.493  - Sec-CH-UA-PLATFORM: linux
#21 3.493  - Content-Type: application/json
#21 3.493 
#21 3.592 2024-08-02T22:31:14.450Z: Request to https://partners.shopify.com/api/cli/graphql completed in 98 ms
#21 3.592 With response headers:
#21 3.592  - cache-control: max-age=0, private, must-revalidate
#21 3.592  - content-type: application/json; charset=utf-8
#21 3.592  - etag: W/"7eb8f76ac991c324b743dc3857f954c7"
#21 3.592  - x-request-id: ba9aeead-4e76-41b7-9bd2-c46244928792-1722637874
#21 3.592     
#21 3.642 2024-08-02T22:31:14.501Z: Sending "Partners" GraphQL request:
#21 3.642   query FindOrganization($id: ID!, $title: String) {
#21 3.642     organizations(id: $id, first: 1) {
#21 3.642       nodes {
#21 3.642         id
#21 3.642         businessName
#21 3.642         apps(first: 25, title: $title) {
#21 3.642           pageInfo {
#21 3.642             hasNextPage
#21 3.642           }
#21 3.642           nodes {
#21 3.642             id
#21 3.642             title
#21 3.642             apiKey
#21 3.642           }
#21 3.642         }
#21 3.642       }
#21 3.642     }
#21 3.642   }
#21 3.642 
#21 3.642 With variables:
#21 3.642 {
#21 3.642   "id": "REDACTED"   <=== Our Shopify Partner ID number was here - should this be the Partner Token?
#21 3.642 }
#21 3.642 
#21 3.642 With request headers:
#21 3.642  - User-Agent: Shopify CLI; v=3.65.0
#21 3.642  - Keep-Alive: timeout=30
#21 3.642  - Sec-CH-UA-PLATFORM: linux
#21 3.642  - Content-Type: application/json
#21 3.642 
#21 3.751 2024-08-02T22:31:14.610Z: Request to https://partners.shopify.com/api/cli/graphql completed in 107 ms
#21 3.751 With response headers:
#21 3.751  - cache-control: max-age=0, private, must-revalidate
#21 3.751  - content-type: application/json; charset=utf-8
#21 3.751  - etag: W/"fdd8f7a18580c87e0e609d921d102b01"
#21 3.751  - x-request-id: a07af39f-ae91-409b-9abd-a5349d76215e-1722637874
#21 3.751     
#21 3.753 
#21 3.753 Before proceeding, your project needs to be associated with an app.
#21 3.753 
#21 3.793 ╭─ error ──────────────────────────────────────────────────────────────────────╮
#21 3.793 │                                                                              │
#21 3.793 │  Failed to prompt:                                                           │
#21 3.793 │                                                                              │
#21 3.793 │  Create this project as a new app on Shopify?                                │
#21 3.793 │                                                                              │
#21 3.793 │  This usually happens when running a command non-interactively, for example  │
#21 3.793 │   in a CI environment, or when piping input from another process.            │
#21 3.793 │                                                                              │
#21 3.793 │  To resolve this, specify the option in the command, or run the command in   │
#21 3.793 │  an interactive environment such as your local terminal.                     │
#21 3.793 │                                                                              │
#21 3.793 ╰──────────────────────────────────────────────────────────────────────────────╯
#21 3.793

Reproduction steps

  1. Dockerfile building a Shopify CLI app that has a valid app ID known at Shopify in the TOML and environment, and a valid Shopify Partner token in the environment.
  2. Build process installs current Shopify CLI rather than relying on what's already installed in the Docker source image.
  3. Execute shopify app deploy --force in that Docker build script.
  4. CLI does not recognize that the app ID is already known to Shopify, the build fails.

Operating System

docker image php:8.1-fpm-alpine

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

3.65.0

Shell

bash

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

20.15.1

What language and version are you using in your application?

Node 20.15

Ulset commented 1 month ago

Having the same issue.

chrisborbidge commented 1 month ago

Same issue here :)

Cycl0n3-ga commented 1 month ago

Same issue....

oinopion commented 1 month ago

I'm experiencing the same problem: CI deployment broke when updating from @shopify/cli 3.64.1 to @shopify/cli 3.65.1. In my case, I'm using --config to choose one between staging and production TOML files, like so:

pnpm run shopify app deploy -f --config sandbox --source-control-url "$COMMIT_URL"
pnpm run shopify app deploy -f --config production --source-control-url "$COMMIT_URL"
austin-tildei commented 1 month ago

This PR which was released in version 3.65.1 sounds like it might be related, but then I'd expect this to be resolved in 3.65.1, which it seems not to be. Maybe there's more needed?

austin-tildei commented 1 month ago

I can also confirm that downgrading from @shopify/cli@3.65.1 to @shopify/cli@3.64.1 fixed this issue for me, which I was seeing when running within GitHub Actions.

nuttmeister commented 4 weeks ago

Same issues here, impossible to deploy via the CLI without going through the manual app linking process of the shopify app deploy command.

Downgrading to 3.64.1 fixes the issue.

Gemorroj commented 3 weeks ago

same. revert to 3.64.* hepls upd. 3.66.0 steel have the problem

gonzaloriestra commented 2 weeks ago

It should be fixed in v3.66.1