From 0586b2d5f67035fee09c67c6d7b1b1800e4e1f15 Mon Sep 17 00:00:00 2001 From: Michal Piechowiak Date: Fri, 21 Jan 2022 16:10:32 +0100 Subject: [PATCH] fix(gatsby-cli): relax error location validation and ignore extra fields --- packages/gatsby-cli/src/structured-errors/error-schema.ts | 2 +- packages/gatsby/src/utils/webpack-error-utils.ts | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/gatsby-cli/src/structured-errors/error-schema.ts b/packages/gatsby-cli/src/structured-errors/error-schema.ts index 306da6d31bdee..d018c061e91c8 100644 --- a/packages/gatsby-cli/src/structured-errors/error-schema.ts +++ b/packages/gatsby-cli/src/structured-errors/error-schema.ts @@ -27,7 +27,7 @@ export const errorSchema: Joi.ObjectSchema = location: Joi.object({ start: Position.required(), end: Position, - }), + }).unknown(), docsUrl: Joi.string().uri({ allowRelative: false, relativeOnly: false, diff --git a/packages/gatsby/src/utils/webpack-error-utils.ts b/packages/gatsby/src/utils/webpack-error-utils.ts index ac16ce191921a..9ae9d58994ec1 100644 --- a/packages/gatsby/src/utils/webpack-error-utils.ts +++ b/packages/gatsby/src/utils/webpack-error-utils.ts @@ -64,7 +64,10 @@ const transformWebpackError = ( if (!location && castedWebpackError.error?.loc) { if (castedWebpackError.error.loc.start) { - location = castedWebpackError.error.loc + location = { + start: castedWebpackError.error.loc.start, + end: castedWebpackError.error.loc.end, + } } else { location = { start: castedWebpackError.error.loc,