Skip to content

Commit e424a32

Browse files
authored
fix(gatsby): Don't crash build when auth token is missing (#7858)
1 parent 5311358 commit e424a32

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

packages/gatsby/gatsby-node.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,15 @@ exports.onCreateWebpackConfig = ({ plugins, getConfig, actions }) => {
4646
// Handle sentry-cli configuration errors when the user has not done it not to break
4747
// the build.
4848
errorHandler(err, invokeErr) {
49-
const { message } = err;
49+
const message = err.message && err.message.toLowerCase() || '';
5050
if (message.includes('organization slug is required') || message.includes('project slug is required')) {
51+
// eslint-disable-next-line no-console
52+
console.log('Sentry [Info]: Not uploading source maps due to missing SENTRY_ORG and SENTRY_PROJECT env variables.')
53+
return;
54+
}
55+
if (message.includes('authentication credentials were not provided')) {
56+
// eslint-disable-next-line no-console
57+
console.warn('Sentry [Warn]: Cannot upload source maps due to missing SENTRY_AUTH_TOKEN env variable.')
5158
return;
5259
}
5360
invokeErr(err);
@@ -93,7 +100,7 @@ function injectSentryConfig(config, configFile) {
93100
} else {
94101
// eslint-disable-next-line no-console
95102
console.error(
96-
`Sentry Logger [Error]: Could not inject SDK initialization code into ${prop}, unexpected format: `,
103+
`Sentry [Error]: Could not inject SDK initialization code into ${prop}, unexpected format: `,
97104
typeof value,
98105
);
99106
}

0 commit comments

Comments
 (0)