stripe / stripe-apps

Stripe Apps lets you embed custom user experiences directly in the Stripe Dashboard and orchestrate the Stripe API.
https://stripe.com/docs/stripe-apps
MIT License
148 stars 73 forks source link

Stripe CLI apps upload failed #947

Closed marco-sacchi closed 9 months ago

marco-sacchi commented 9 months ago

Describe the bug The stripe apps upload CLI command ends with the following error:

marco@marco-ubuntu:~/modulo/progetti/stripe/test$ stripe apps upload --log-level debug
[Wed, 14 Feb 2024 11:08:16 CET] DEBUG config.Config.InitConfig: Using profiles file path=/home/marco/.config/stripe/config.toml
[Wed, 14 Feb 2024 11:08:16 CET] DEBUG config.Config.GetProfilesFolder: Using profiles file path=/home/marco/.config/stripe
[Wed, 14 Feb 2024 11:08:16 CET] DEBUG cmd.pluginCmd.runPluginCmd: Running plugin...
[Wed, 14 Feb 2024 11:08:16 CET] DEBUG config.Config.GetProfilesFolder: Using profiles file path=/home/marco/.config/stripe
[Wed, 14 Feb 2024 11:08:16 CET] DEBUG config.Config.GetProfilesFolder: Using profiles file path=/home/marco/.config/stripe
[Wed, 14 Feb 2024 11:08:16 CET] DEBUG plugins.plugin.Run: negotiated gRPC with plugin process
2024-02-14T11:08:18.127+0100 [ERROR] plugin.child.apps: plugin process exited: path=/home/marco/.config/stripe/plugins/apps/1.5.14/stripe-cli-apps pid=9520 error="exit status 2"
[Wed, 14 Feb 2024 11:08:18 CET] DEBUG Tearing down plugin before exit
[Wed, 14 Feb 2024 11:08:18 CET] DEBUG pluginTemplateCmd.runPluginCmd: Plugin command 'apps' exited with error: rpc error: code = Unavailable desc = error reading from server: EOF

To Reproduce Steps to reproduce the behavior:

  1. Enable the CLI following this guide: https://stripe.com/docs/stripe-apps/create-app (I use apt)
  2. stripe login
  3. stripe apps create test --log-level debug (test app based on "hello-world" template will be created)
  4. stripe apps upload --log-level debug
  5. The command fails

Expected behavior The app will be uploaded into Stripe.

Screenshots -Not applicable-

Desktop (please complete the following information):

Desktop 2 (please complete the following information):

Desktop 3 (please complete the following information):

Same behavior on all desktops. On macOS and arch brew/pacman, node.js, stripe cli were installed from scratch.

Additional context

I have read the other issues that concern app uploading, but none have solved this problem.

I currently need to create an app without UI, which is used only to allow the user to authenticate the OAuth 2.0 flow to integrate our PigrecoOS platform with Stripe, mainly to manage products payment/checkout, as already done for Paypal. I reverted to this "hello world" to verify that the problem was not due to changes I had made.

I have successfully implemented and executed the API requests using the private key in test mode using the PHP SDK. But given this notice, an application is still required to prevent our customers from having to enter their private keys into the backend of our platform.

Commands executed successfully:

Please note: this key will expire after 90 days, at which point you'll need to re-authenticate.


- `stripe apps start` the app preview displays correctly

^Cmarco@marco-ubuntu:~/modulo/progetti/stripe/test$ stripe apps start --log-level debug [Wed, 14 Feb 2024 11:36:41 CET] DEBUG config.Config.InitConfig: Using profiles file path=/home/marco/.config/stripe/config.toml [Wed, 14 Feb 2024 11:36:41 CET] DEBUG config.Config.GetProfilesFolder: Using profiles file path=/home/marco/.config/stripe [Wed, 14 Feb 2024 11:36:41 CET] DEBUG cmd.pluginCmd.runPluginCmd: Running plugin... [Wed, 14 Feb 2024 11:36:41 CET] DEBUG config.Config.GetProfilesFolder: Using profiles file path=/home/marco/.config/stripe [Wed, 14 Feb 2024 11:36:41 CET] DEBUG config.Config.GetProfilesFolder: Using profiles file path=/home/marco/.config/stripe [Wed, 14 Feb 2024 11:36:41 CET] DEBUG plugins.plugin.Run: negotiated gRPC with plugin process [11:36:42] compiled successfully 💻 Running development server on http://localhost:4242 (^C to quit) ✨ You can now preview Test in your Stripe account.

🌐 Press Enter to open the Stripe dashboard

^C[Wed, 14 Feb 2024 11:39:26 CET] DEBUG cmd.pluginCmd.runPluginCmd: Ctrl+C received, cleaning up... [Wed, 14 Feb 2024 11:39:26 CET] DEBUG Tearing down plugin before exit

- `stripe plugin upgrade apps` (I already have the 1.5.14 version)

marco@marco-ubuntu:~/modulo/progetti/stripe/PigrecoOS$ stripe plugin upgrade apps ✔ upgrade to v1.5.14 complete.


Terminal output:

marco@marco-ubuntu:~/modulo/progetti/stripe$ stripe apps create test --log-level debug [Wed, 14 Feb 2024 10:54:17 CET] DEBUG config.Config.InitConfig: Using profiles file path=/home/marco/.config/stripe/config.toml [Wed, 14 Feb 2024 10:54:17 CET] DEBUG config.Config.GetProfilesFolder: Using profiles file path=/home/marco/.config/stripe [Wed, 14 Feb 2024 10:54:17 CET] DEBUG cmd.pluginCmd.runPluginCmd: Running plugin... [Wed, 14 Feb 2024 10:54:17 CET] DEBUG config.Config.GetProfilesFolder: Using profiles file path=/home/marco/.config/stripe [Wed, 14 Feb 2024 10:54:17 CET] DEBUG config.Config.GetProfilesFolder: Using profiles file path=/home/marco/.config/stripe [Wed, 14 Feb 2024 10:54:18 CET] DEBUG plugins.plugin.Run: negotiated gRPC with plugin process

🖊️ Enter details of your new Stripe app (these can be changed later) App ID: com.example.test Display name: Test ✔ Created skeleton files based on "hello-world" template installing dev dependencies... @stripe/ui-extension-tools npm WARN deprecated abab@2.0.6: Use your platform's native atob() and btoa() methods instead npm WARN deprecated domexception@2.0.1: Use your platform's native DOMException instead npm WARN deprecated w3c-hr-time@1.0.2: Use your platform's native performance.now() and performance.timeOrigin.

added 592 packages, and audited 593 packages in 32s

124 packages are looking for funding run npm fund for details

found 0 vulnerabilities installing dependencies... stripe @stripe/ui-extension-sdk

up to date, audited 593 packages in 1s

124 packages are looking for funding run npm fund for details

found 0 vulnerabilities ✔ Installed dependencies ✔ Created Test at /home/marco/modulo/progetti/stripe Inside that directory, you can run several commands:

$ stripe apps start Start a development server locally for viewing your app in the Stripe dashboard

$ stripe apps add view Add a new view to your app

$ stripe apps upload Upload your app to be submitted for review

To get started, try starting the development server from the app directory:

$ cd test $ stripe apps start [Wed, 14 Feb 2024 10:54:56 CET] DEBUG Tearing down plugin before exit marco@marco-ubuntu:~/modulo/progetti/stripe$ cd test marco@marco-ubuntu:~/modulo/progetti/stripe/test$ stripe apps upload --log-level debug [Wed, 14 Feb 2024 11:08:16 CET] DEBUG config.Config.InitConfig: Using profiles file path=/home/marco/.config/stripe/config.toml [Wed, 14 Feb 2024 11:08:16 CET] DEBUG config.Config.GetProfilesFolder: Using profiles file path=/home/marco/.config/stripe [Wed, 14 Feb 2024 11:08:16 CET] DEBUG cmd.pluginCmd.runPluginCmd: Running plugin... [Wed, 14 Feb 2024 11:08:16 CET] DEBUG config.Config.GetProfilesFolder: Using profiles file path=/home/marco/.config/stripe [Wed, 14 Feb 2024 11:08:16 CET] DEBUG config.Config.GetProfilesFolder: Using profiles file path=/home/marco/.config/stripe [Wed, 14 Feb 2024 11:08:16 CET] DEBUG plugins.plugin.Run: negotiated gRPC with plugin process 2024-02-14T11:08:18.127+0100 [ERROR] plugin.child.apps: plugin process exited: path=/home/marco/.config/stripe/plugins/apps/1.5.14/stripe-cli-apps pid=9520 error="exit status 2" [Wed, 14 Feb 2024 11:08:18 CET] DEBUG Tearing down plugin before exit [Wed, 14 Feb 2024 11:08:18 CET] DEBUG pluginTemplateCmd.runPluginCmd: Plugin command 'apps' exited with error: rpc error: code = Unavailable desc = error reading from server: EOF


The `stripe-app.json` manifest has not been modified in any way and contains:
```json
{
    "id": "com.example.test",
    "version": "0.0.1",
    "name": "Test",
    "icon": "",
    "permissions": [],
    "ui_extension": {
        "views": [
            {
                "viewport": "stripe.dashboard.customer.detail",
                "component": "App"
            }
        ],
        "content_security_policy": {
            "connect-src": null,
            "image-src": null,
            "purpose": ""
        }
    }
}
bensontrent commented 9 months ago

One thing that stood out to me in your manifest was the name of your id. When you upload, you'll need to change the id of com.example.test in your stripe-app.json to something unique as it's likely that id has already been uploaded by another developer. Apps running locally don't have that requirement.

marco-sacchi commented 9 months ago

One thing that stood out to me in your manifest was the name of your id. When you upload, you'll need to change the id of com.example.test in your stripe-app.json to something unique as it's likely that id has already been uploaded by another developer. Apps running locally don't have that requirement.

The app I had written previously had the id srl.modulo.stripe and now I set this "hello world" to srl.modulo.test-pigrceoos without the result changing.

If you look more carefully at the logs you will see these lines:

2024-02-14T19:19:32.003+0100 [ERROR] plugin.child.apps: plugin process exited:
path=/home/marco/.config/stripe/plugins/apps/1.5.14/stripe-cli-apps pid=14631 error="exit status 2"

which in my opinion indicate a problem in the apps plugin.

Note that I don't get any specific output from that plugin, like in the examples I saw in the documentation, where manifest validation is logged for example.

I saw from the help of the stripe plugin install command that it is possible to indicate a specific version via the [name]@[version] syntax, but I couldn't find any information in your documentation or here on github about what the older versions are, otherwise I would have attempted to install an older version of the plugin.

bensontrent commented 9 months ago

I'm able to use stripe apps upload fine. Perhaps there's another version problem? Here's my configuration:

node -v
v20.11.0

stripe -v
stripe version 1.14.7

stripe apps -v
apps version 1.5.14
marco-sacchi commented 9 months ago

I'm able to use stripe apps upload fine. Perhaps there's another version problem? Here's my configuration:

node -v
v20.11.0

stripe -v
stripe version 1.14.7

stripe apps -v
apps version 1.5.14
  • I should note that I'm not a Stripe employee, just a developer who has a interest in the success of Stripe Apps as a platform.
marco@marco-ubuntu:~/modulo/progetti/stripe/test$ node -v
v21.6.2
marco@marco-ubuntu:~/modulo/progetti/stripe/test$ stripe -v
stripe version 1.19.2
marco@marco-ubuntu:~/modulo/progetti/stripe/test$ stripe apps -v
apps version 1.5.14

This means it is not the apps plugin. I will try to downgrade stripe cli.

update

marco@marco-ubuntu:~/modulo/progetti/stripe/test$ node -v
v21.6.2
marco@marco-ubuntu:~/modulo/progetti/stripe/test$ stripe -v
stripe version 1.14.7
marco@marco-ubuntu:~/modulo/progetti/stripe/test$ stripe apps -v
apps version 1.5.14

and it still doesn't work

bensontrent commented 9 months ago

You should also be aware that when running stripe apps upload there are more strict checks in place to ensure your code runs correctly and there are no typescript or in some cases, eslint errors. Not all the examples are feature complete, for example, you will need to run npm i before uploading an app. Running stripe apps start is more forgiving as it's intended to be a developer localhost environment.

Check your code by verifying stripe apps start creates an error-free app in your Stripe dashboard.

marco-sacchi commented 9 months ago

You should also be aware that when running stripe apps upload there are more strict checks in place to ensure your code runs correctly and there are no typescript or in some cases, eslint errors. Not all the examples are feature complete, for example, you will need to run npm i before uploading an app. Running stripe apps start is more forgiving as it's intended to be a developer localhost environment.

Check your code by verifying stripe apps start creates an error-free app in your Stripe dashboard.

Thanks for the support.

marco@marco-ubuntu:~/modulo/progetti/stripe/test$ npm run lint

> com.example.test@0.0.1 lint
> eslint --ext ts,tsx src

/home/marco/modulo/progetti/stripe/test/src/views/App.tsx
  11:16  warning  'userContext' is defined but never used  @typescript-eslint/no-unused-vars
  11:29  warning  'environment' is defined but never used  @typescript-eslint/no-unused-vars

✖ 2 problems (0 errors, 2 warnings)
marco@marco-ubuntu:~/modulo/progetti/stripe/test$ npm run test

> com.example.test@0.0.1 test
> jest

 PASS  src/views/App.test.tsx
  App
    ✓ renders ContextView (10 ms)

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        3.189 s
Ran all test suites.
marco@marco-ubuntu:~/modulo/progetti/stripe/test$ npm i

up to date, audited 593 packages in 2s

124 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

As you can see there are no vulnerabilities or problems in the tests, but only two unused variables.

The stripe apps start command runs correctly and the app is correctly previewed in the dashboard.

marco-sacchi commented 9 months ago

Additional information for the stripe golang team.

Looking at the request logs for my CLI key in the Stripe dashboard, I was able to isolate one that is definitely related to the stripe apps upload command and which fails with code 404:

code method uri timestamp
404 ERR GET /v1/tailor/app_by_public_id 13:59:05
200 OK GET /v1/tailor/terms_acceptance_byaccount/acct*****/valid 13:59:04
200 OK GET /v1/tailor/terms_acceptance_byaccount/acct*****/valid 13:57:41
GET /v1/tailor/app_by_public_id
Stato     404 ERR
ID        req_6h9FrrMuLnzsHF
Orario    15/02/24, 13:59:05
Indirizzo IP ***.***.***.***
Versione  API [2023-10-16](https://stripe.com/docs/upgrades#2023-10-16)
Origine   Stripe/v1 stripe-cli/master

Request query parameters:

{
  "public_id": "srl.modulo.test-pigrecoos"
}

Response body:

{
  "error": {
    "code": "resource_missing",
    "doc_url": "https://stripe.com/docs/error-codes/resource-missing",
    "message": "No such app: srl.modulo.test-pigrecoos",
    "request_log_url": "https://dashboard.stripe.com/test/logs/req_6h9FrrMuLnzsHF?t=1708005545",
    "type": "invalid_request_error"
  }
}

Maybe I'm doing something wrong, but I followed your documentation carefully.

jessechan-stripe commented 9 months ago

Hi @marco-sacchi,

The team took a look at this and were having trouble reproducing the error. Do you mind including a video recording, so we can help troubleshoot further?

svenugopal-stripe commented 9 months ago

Hello @marco-sacchi, We have identified the underlying problem and made a fix. Could you please update the apps plugin by running

❯ stripe plugin upgrade apps

and verify it is 1.5.15

❯ stripe apps version
stripe apps
 version: 1.5.15
 git-sha: ee99516
 build-time: 2024-02-15 19:48:43 +0000 UTC

Apologies for the inconvenience this bug has caused.

svenugopal-stripe commented 9 months ago

closing this bug for now. If you run into any issues please re-open or open a new one.