I am using Sentry for logging, and Vercel blocks my build process with the error below.
Edit Update:
Vercel’s env pull command checks my build process’s process.env for SENTRY_DSN and decides whether to allow my build process to continue based on what it finds, including local variables I defined in .xcconfig and not only in the variables I’ve defined through Vercel:
node_modules/vercel/dist/index.js
Line 11733
if (options.dsn === void 0 && process.env.SENTRY_DSN) {
options.dsn = process.env.SENTRY_DSN;
}
Line 178094
Sentry.init({
dsn: SENTRY_DSN,
release: `vercel-cli@${pkg_default.version}`,
environment: "stable"
});
I think this is happening because Vercel itself uses Sentry for logging and is validating what it thinks is it’s own SENTRY_DSN.
Original Post
I want to pull down my Sentry Project’s DSN that I’ve stored as an environment variable in my Vercel project. However, I am pulling this value from Vercel in order to use it in an iOS application (I am appending SENTRY_DSN = <value>
to an .xcconfig file.) Because of a quirk in Xcode, I cannot use the whole https://<DSN url>
in the .xcconfig file, so I have to use only the part after the url scheme (omitting https://
) and then prepend the url scheme in code. This causes a problem with Vercel. Apparently Vercel is detecting that this is a Sentry DSN and trying to validate it on my behalf, then finding it malformed and rejecting the value, causing my whole build process to fail.
I have looked at the source code referenced in the error and it looks like Vercel imports a Sentry module to validate these DSN urls. Can someone from Vercel verify whether this is really what’s happening?
(This is the Sentry module imported by Vercel at the location of the Vercel code referenced by the error below: “…/…/node_modules/.pnpm/@sentry+core@5.5.0/node_modules/@sentry/core/dist/dsn.js”)
Pulling dev .env from vercel
/opt/homebrew/Cellar/vercel-cli/34.2.7/libexec/lib/node_modules/vercel/dist/index.js:7910
throw new utils_1.SentryError(ERROR_MESSAGE);
^
SentryError2: Invalid Dsn
at new SentryError2 (/opt/homebrew/Cellar/vercel-cli/34.2.7/libexec/lib/node_modules/vercel/dist/index.js:6190:30)
at Dsn2._fromString (/opt/homebrew/Cellar/vercel-cli/34.2.7/libexec/lib/node_modules/vercel/dist/index.js:7910:19)
at new Dsn2 (/opt/homebrew/Cellar/vercel-cli/34.2.7/libexec/lib/node_modules/vercel/dist/index.js:7894:18)
at NodeBackend2._setupTransport (/opt/homebrew/Cellar/vercel-cli/34.2.7/libexec/lib/node_modules/vercel/dist/index.js:10858:21)
at NodeBackend2.BaseBackend2 (/opt/homebrew/Cellar/vercel-cli/34.2.7/libexec/lib/node_modules/vercel/dist/index.js:8375:34)
at new NodeBackend2 (/opt/homebrew/Cellar/vercel-cli/34.2.7/libexec/lib/node_modules/vercel/dist/index.js:10852:44)
at NodeClient2.BaseClient2 (/opt/homebrew/Cellar/vercel-cli/34.2.7/libexec/lib/node_modules/vercel/dist/index.js:8111:27)
at new NodeClient2 (/opt/homebrew/Cellar/vercel-cli/34.2.7/libexec/lib/node_modules/vercel/dist/index.js:10940:25)
at Object.initAndBind (/opt/homebrew/Cellar/vercel-cli/34.2.7/libexec/lib/node_modules/vercel/dist/index.js:8411:40)
at Object.init3 (/opt/homebrew/Cellar/vercel-cli/34.2.7/libexec/lib/node_modules/vercel/dist/index.js:11750:14)