getsentry / sentry-wizard

Sentry Project Setup Wizard
MIT License
192 stars 48 forks source link

TypeError when there's no projects to select from #400

Closed kevduc closed 1 year ago

kevduc commented 1 year ago

Environment

@sentry/wizard version: 3.9.2 | sentry-cli version: 1.75.2 Windows 10

Steps to Reproduce

  1. Create a new sentry account
  2. Create a new Next.js project
  3. From the project folder, run npx @sentry/wizard@latest -i nextjs
  4. Select Sentry SaaS (sentry.io) for Are you using Sentry SaaS or self-hosted Sentry?
  5. Answer Yes to Do you already have a Sentry account?
  6. There's a type error (see console output at the end)

Expected Result

I landed on https://sentry.io/for/nextjs/ (from a google search), it says it's a one line setup with npx @sentry/wizard@latest -i nextjs. I already had a sentry account, but without any projects in it, I expected the wizard to create the sentry project in my account for me, but it errors out in that case.

Actual Result

> npx @sentry/wizard@latest -i nextjs --debug   
{
        "_": [],
        "i": "nextjs",
        "integration": "nextjs",
        "debug": true,
        "uninstall": false,
        "skip-connect": false,
        "skipConnect": false,
        "quiet": false,
        "s": false,
        "signup": false,
        "disable-telemetry": false,
        "disableTelemetry": false,
        "$0": "C:\\Users\\xyz\\AppData\\Local\\npm-cache\\_npx\\ddb126e78325956c\\node_modules\\@sentry\\wizard\\dist\\bin.js"
}
Running Sentry Wizard...
version: 3.9.2 | sentry-cli version: 1.75.2
Sentry Wizard will help you to configure your project
Thank you for using Sentry :)
Skipping connection to Sentry due files already patched

{
        "integration": {
                "_argv": {
                        "_": [],
                        "i": "nextjs",
                        "integration": "nextjs",
                        "debug": true,
                        "uninstall": false,
                        "skip-connect": false,
                        "skipConnect": false,
                        "quiet": false,
                        "s": false,
                        "signup": false,
                        "disable-telemetry": false,
                        "disableTelemetry": false,
                        "$0": "C:\\Users\\xyz\\AppData\\Local\\npm-cache\\_npx\\ddb126e78325956c\\node_modules\\@sentry\\wizard\\dist\\bin.js"
                },
                "_isDebug": true
        }
}

{
        "integration": {
                "_argv": {
                        "_": [],
                        "i": "nextjs",
                        "integration": "nextjs",
                        "debug": true,
                        "uninstall": false,
                        "skip-connect": false,
                        "skipConnect": false,
                        "quiet": false,
                        "s": false,
                        "signup": false,
                        "disable-telemetry": false,
                        "disableTelemetry": false,
                        "$0": "C:\\Users\\xyz\\AppData\\Local\\npm-cache\\_npx\\ddb126e78325956c\\node_modules\\@sentry\\wizard\\dist\\bin.js"
                },
                "_isDebug": true
        }
}

┌   Sentry Next.js Wizard 
│
◇   ──────────────────────────────────────────────────────────────╮
│                                                                 │
│  This Wizard will help you set up Sentry for your application.  │
│  Thank you for using Sentry :)                                  │
│                                                                 │
│  Version: 3.9.2                                                 │
│                                                                 │
├─────────────────────────────────────────────────────────────────╯
│
◇  Are you using Sentry SaaS or self-hosted Sentry?
│  Sentry SaaS (sentry.io)
│
◇  Do you already have a Sentry account?
│  Yes
│
●  If the browser window didn't open automatically, please open the following link to log into Sentry:
│
│  https://sentry.io/account/settings/wizard/abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef/
│
◇  Login complete.

TypeError: Cannot read properties of undefined (reading 'value')
    at SelectPrompt.changeValue (C:\Users\xyz\AppData\Local\npm-cache\_npx\ddb126e78325956c\node_modules\@clack\core\dist\index.cjs:14:3567)
    at new SelectPrompt (C:\Users\xyz\AppData\Local\npm-cache\_npx\ddb126e78325956c\node_modules\@clack\core\dist\index.cjs:14:3235)
    at windowedSelect (C:\Users\xyz\AppData\Local\npm-cache\_npx\ddb126e78325956c\node_modules\@sentry\wizard\dist\src\utils\vendor\clack-custom-select.js:91:12)
    at C:\Users\xyz\AppData\Local\npm-cache\_npx\ddb126e78325956c\node_modules\@sentry\wizard\dist\src\utils\clack-utils.js:319:104
    at step (C:\Users\xyz\AppData\Local\npm-cache\_npx\ddb126e78325956c\node_modules\@sentry\wizard\dist\src\utils\clack-utils.js:56:23)
    at Object.next (C:\Users\xyz\AppData\Local\npm-cache\_npx\ddb126e78325956c\node_modules\@sentry\wizard\dist\src\utils\clack-utils.js:37:53)
    at C:\Users\xyz\AppData\Local\npm-cache\_npx\ddb126e78325956c\node_modules\@sentry\wizard\dist\src\utils\clack-utils.js:31:71
    at new Promise (<anonymous>)
    at __awaiter (C:\Users\xyz\AppData\Local\npm-cache\_npx\ddb126e78325956c\node_modules\@sentry\wizard\dist\src\utils\clack-utils.js:27:12)
    at askForProjectSelection (C:\Users\xyz\AppData\Local\npm-cache\_npx\ddb126e78325956c\node_modules\@sentry\wizard\dist\src\utils\clack-utils.js:315:12)

Additional information

It seems to be related to https://github.com/getsentry/sentry-wizard/issues/26

The wizard should probably ask the user if they want to create a sentry project, and create the project for them, or at least let them know they need to first create a project in sentry (maybe give them a url).

The error itself comes from @clack/core (the options parameter for SelectPrompt called here is mistyped, see https://github.com/natemoo-re/clack/issues/144), but is pretty much separate from the current issue, i.e. in any case, the wizard should handle the case when the project array is empty, and not prompt the user to select from an empty list of projects.

Lms24 commented 1 year ago

Hi @kevduc thanks for reporting and for the detailed issue description! We'll take a look at this.

kevduc commented 1 year ago

Thank you! Also step 2 in the reproduction steps might be ambiguous, what I meant is "Create a new Next.js project locally on your computer" e.g. with npx create-next-app@latest (and not: create a Next.js sentry project in your sentry account)