getsentry / sentry-javascript-bundler-plugins

JavaScript Bundler Plugins for Sentry
https://sentry.io
BSD 3-Clause "New" or "Revised" License
141 stars 36 forks source link

Invalid org token in Vite build #566

Closed Soviut closed 4 months ago

Soviut commented 4 months ago

Environment

node 20.15.0 vite 5.3.2 @sentry/vite-plugin 2.20.1

Steps to Reproduce

Configure vite.config.mts with

import { sentryVitePlugin } from '@sentry/vite-plugin'

export default defineConfig({
  plugins: [
    vue(),
    sentryVitePlugin({
      org: 'myorg',
      project: 'my-project',
    }),
  ]
})

Note that the org is my "organization slug".

The main error being Invalid org token (http status: 401)

Expected Result

I should be able to run npm run build and my org setting (my organization slug) should be valid. The build should pass.

Actual Result

When I run npm run build and get the following error.

error: API request failed
  caused by: sentry reported an error: Invalid org token (http status: 401)

Add --log-level=[info|debug] or export SENTRY_LOG_LEVEL=[info|debug] to see more output.
Please attach the full debug log to all bug reports.
[sentry-vite-plugin] Info: Successfully uploaded source maps to Sentry
x Build failed in 5.47s
error during build:
[sentry-debug-id-upload-plugin] Command failed: /home/soviut/projects/my-project/node_modules/@sentry/cli-linux-x64/bin/sentry-cli releases new 18fb9ab7f75046e4085423e2aa660629d8e354aa
error: API request failed
  caused by: sentry reported an error: Invalid org token (http status: 401)

Add --log-level=[info|debug] or export SENTRY_LOG_LEVEL=[info|debug] to see more output.
Please attach the full debug log to all bug reports.

    at genericNodeError (node:internal/errors:984:15)
    at wrappedFn (node:internal/errors:538:14)
    at ChildProcess.exithandler (node:child_process:422:12)
    at ChildProcess.emit (node:events:519:28)
    at maybeClose (node:internal/child_process:1105:16)
    at ChildProcess._handle.onexit (node:internal/child_process:305:5)
andreiborza commented 4 months ago

Hello, thanks for writing in!

Just to confirm, do you have a valid auth token in your .env.sentry-build-plugin file? If you run our wizard it should generate a valid token for you, see https://docs.sentry.io/platforms/javascript/sourcemaps/uploading/vite/#automatic-setup.

Soviut commented 4 months ago

@andreiborza That was it. I completely forgot about the .env.sentry-build-plugin file.

What's frustrating is I even explicitly set a SENTRY_AUTH_TOKEN in my .env.local but it was missing quotes so the = sign later on in the key must have confused it.