getsentry / sentry-cli

A command line utility to work with Sentry.
https://docs.sentry.io/cli/
BSD 3-Clause "New" or "Revised" License
896 stars 222 forks source link

error: Two different url values supplied: `https://sentry.myweb.com` (from token), `https://sentry.io`. #2085

Closed SouthLink closed 2 months ago

SouthLink commented 3 months ago

CLI Version

latest

Operating System and Architecture

Operating System Version

Linux version 3.10.0-862.3.2.el7.x86_64 (builder@kbuilder.dev.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-28) (GCC) ) #1 SMP Mon May 21 23:36:36 UTC 2018

Link to reproduction repository

No response

CLI Command

No response

Exact Reproduction Steps

My project uses sentry self-hosting and @sentry/nextjs and docker 、gitlab-cli to build my project, but the source map upload error occurs when uploading at build time:

sentry 24.3.0 @sentry/nextjs 8.7.0

// next.config.js
const sentryConfig = {
url: 'https://sentry.myweb.com/',
org: "my",
project: "my-projext",
token: "64659xxx",
authToken: "sntrys_xxxx",

hideSourceMaps: true,
silent: true,
widenClientFileUpload: true,
};

module.exports = withSentryConfig(nextConfig), sentryConfig)
unhandledRejection Error: Command failed: /www/node_modules/.pnpm/@sentry+cli-linux-x64@2.32.1/node_modules/@sentry/cli-linux-x64/bin/sentry-cli releases new lBTYPKkG5XWZRWBufz33z
error: Two different url values supplied: `https://sentry.myweb.com/` (from token), `https://sentry.io/`.
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 ChildProcess.exithandler (node:child_process:422:12)
    at ChildProcess.emit (node:events:517:28)
    at ChildProcess.emit (node:domain:489:12)
    at maybeClose (node:internal/child_process:1098:16)
    at ChildProcess._handle.onexit (node:internal/child_process:303:5) {
  code: 1,
  killed: false,
  signal: null,
  cmd: '/www/node_modules/.pnpm/@sentry+cli-linux-x[64](https://xxx/next/-/jobs/2143239#L64)@2.32.1/node_modules/@sentry/cli-linux-x64/bin/sentry-cli releases new lBTYPKkG5XWZRWBufz33z'
}

What worked for me was to use.sentryclirc to create my token instead of using the sentry webpack configuration of next.config.js, and while the build was successful, I couldn't see the sourcemap upload, which I thought was a serious problem

Expected Results

The source map was uploaded successfully

Actual Results

error: Two different url values supplied: https://sentry.myweb.com/ (from token), https://sentry.io/.

Logs

unhandledRejection Error: Command failed: /www/node_modules/.pnpm/@sentry+cli-linux-x64@2.32.1/node_modules/@sentry/cli-linux-x64/bin/sentry-cli releases new lBTYPKkG5XWZRWBufz33z
error: Two different url values supplied: `https://sentry.myweb.com/` (from token), `https://sentry.io/`.
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 ChildProcess.exithandler (node:child_process:422:12)
    at ChildProcess.emit (node:events:517:28)
    at ChildProcess.emit (node:domain:489:12)
    at maybeClose (node:internal/child_process:1098:16)
    at ChildProcess._handle.onexit (node:internal/child_process:303:5) {
  code: 1,
  killed: false,
  signal: null,
  cmd: '/www/node_modules/.pnpm/@sentry+cli-linux-x[64](https://xxx/next/-/jobs/2143239#L64)@2.32.1/node_modules/@sentry/cli-linux-x64/bin/sentry-cli releases new lBTYPKkG5XWZRWBufz33z'
}
szokeasaurusrex commented 3 months ago

This seems strange – I can see that you are specifying url: 'https://sentry.myweb.com/' in your configuration, but for some reason, it appears that somewhere else it is being set to https://sentry.io.

Could you try again without specifying the URL? Since you are using an org auth token (which I can identify from the prefix sntrys_), specifying a URL is unnecessary – the org auth token already encodes the URL.


What worked for me was to use.sentryclirc to create my token instead of using the sentry webpack configuration of next.config.js, and while the build was successful, I couldn't see the sourcemap upload, which I thought was a serious problem

I did not understand this part of your issue report – .sentryclirc is a configuration file, you cannot use it to create a token. Auth tokens need to be created in the Sentry web UI.

SouthLink commented 3 months ago

这看起来很奇怪——我可以看到您在配置中指定了url: 'https://sentry.myweb.com/',但是出于某种原因,似乎在其他地方它被设置为https://sentry.io

您能否在不指定 URL 的情况下重试?由于您使用的是 org auth 令牌(我可以从前缀 识别sntrys_),因此无需指定 URL - org auth 令牌已对 URL 进行编码。

对我有用的是使用 .sentryclirc 来创建我的 token,而不是使用 next.config.js 的 sentry webpack 配置,虽然构建成功,但我看不到 sourcemap 上传,我认为这是一个严重的问题

我不明白你问题报告中的这部分内容——.sentryclirc这是一个配置文件,你不能用它来创建令牌。需要在 Sentry Web UI 中创建身份验证令牌。

Thank you for your answer

I tried not specifying the url field or not configurating.sentryclirc it still prompts this error, I wonder if somewhere my organization url was reset to https://sentry.io.

Follow-up: I solved this problem by adding environment variables to the docker file,

ENV SENTRY_URL https://sentry.myweb.com

But when I see the build log, there is no prompt for sentry to build the source map and upload the source map log. I don't know if this is the default configuration. It seems that this is normal in the v7 version of @sentry/nextjs

Step 10/17 : RUN pnpm run build:test
---> Running in bf05f561ebef
> myweb-next@0.1.0 build:test /www
> cross-env NODE_ENV=test next build
Attention: Next.js now collects completely anonymous telemetry regarding usage.
This information is used to shape Next.js' roadmap and prioritize features.
You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
https://nextjs.org/telemetry
▲ Next.js 14.0.0
- Environments: .env.test
Creating an optimized production build ...
⚠ Custom webpack configuration is detected. When using a custom webpack configuration, the Webpack build worker is disabled by default. To force enable it, set the "experimental.webpackBuildWorker" option to "true". Read more: https://nextjs.org/docs/messages/webpack-build-worker-opt-out
Disabled SWC as replacement for Babel because of custom Babel configuration ".babelrc" https://nextjs.org/docs/messages/swc-disabled
Using external babel configuration from /www/.babelrc
⚠ Compiled with warnings
./node_modules/.pnpm/next@14.0.0_@babel+core@7.23.7_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0_sass@1.72.0/node_modules/next/dist/esm/shared/lib/router/utils/app-paths.js
A Node.js module is loaded ('url' at line 3) which is not supported in the Edge Runtime.
Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime
Import trace for requested module:
./node_modules/.pnpm/next@14.0.0_@babel+core@7.23.7_@opentelemetry+api@1.8.0_react-dom@18.2.0_react@18.2.0_sass@1.72.0/node_modules/next/dist/esm/shared/lib/router/utils/app-paths.js
Skipping validation of types
Linting ...
⨯ ESLint: Failed to load config "prettier" to extend from. Referenced from: /www/.eslintrc.json
Collecting page data ...
Generating static pages (0/10) ...
Generating static pages (2/10)
Generating static pages (4/10)
Generating static pages (7/10)
✓ Generating static pages (10/10)
Finalizing page optimization ...
Collecting build traces ...
Route (app)                              Size     First Load JS
┌ λ /                                    150 B          96.1 kB
├ λ /_not-found                          879 B          96.8 kB
├ λ /test                                229 B          96.2 kB
├ λ /usedauto                            150 B          96.1 kB
├ λ /usedauto/infos                      150 B          96.1 kB
├ λ /usedauto/publicity                  151 kB          267 kB
└ λ /usedauto/userinfos                  150 B          96.1 kB
+ First Load JS shared by all            95.9 kB
├ chunks/835-40d71f694b3395d6.js       40.5 kB
├ chunks/86979ae6-d3a81905dddd5193.js  53.3 kB
├ chunks/main-app-7379d5375f237dad.js  232 B
└ chunks/webpack-0ac6033e47707a13.js   1.94 kB
ƒ Middleware                             28.5 kB
λ  (Dynamic)  server-rendered on demand using Node.js
Removing intermediate container bf05f561ebef
---> 85c6cd4e536c
szokeasaurusrex commented 3 months ago

But when I see the build log, there is no prompt for sentry to build the source map and upload the source map log. I don't know if this is the default configuration. It seems that this is normal in the v7 version of @sentry/nextjs

@SouthLink I am a bit confused by this comment. I don't know how you have your project configured, so I am not sure whether you have your project set up correctly to upload source maps.

If you check in Sentry, are you able to see that your source maps were uploaded in your project settings (under the "Source Maps" section)? Can you see stack traces in your errors? If the answer to both questions is "yes," then you have source maps set up correctly.

SouthLink commented 2 months ago

But when I see the build log, there is no prompt for sentry to build the source map and upload the source map log. I don't know if this is the default configuration. It seems that this is normal in the v7 version of @sentry/nextjs

@SouthLink I am a bit confused by this comment. I don't know how you have your project configured, so I am not sure whether you have your project set up correctly to upload source maps.

If you check in Sentry, are you able to see that your source maps were uploaded in your project settings (under the "Source Maps" section)? Can you see stack traces in your errors? If the answer to both questions is "yes," then you have source maps set up correctly.

Thank you. I found my original map and uploaded it

gomjellie commented 2 months ago

@SouthLink this might help

// next.config.js
const sentryConfig = {
- url: 'https://sentry.myweb.com/',
+ sentryUrl: 'https://sentry.myweb.com/'
org: "my",
project: "my-projext",
token: "64659xxx",
authToken: "sntrys_xxxx",

hideSourceMaps: true,
silent: true,
widenClientFileUpload: true,
};

module.exports = withSentryConfig(nextConfig), sentryConfig)
SouthLink commented 2 months ago

@SouthLink this might help

// next.config.js
const sentryConfig = {
- url: 'https://sentry.myweb.com/',
+ sentryUrl: 'https://sentry.myweb.com/'
org: "my",
project: "my-projext",
token: "64659xxx",
authToken: "sntrys_xxxx",

hideSourceMaps: true,
silent: true,
widenClientFileUpload: true,
};

module.exports = withSentryConfig(nextConfig), sentryConfig)

Thank you. I'll try your configuration

0xvictorb commented 1 month ago

@SouthLink this might help

// next.config.js const sentryConfig = {

hideSourceMaps: true, silent: true, widenClientFileUpload: true, };

module.exports = withSentryConfig(nextConfig), sentryConfig)

Thank you, you saved my day