@netlify/build 29.26.3 → 29.26.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/core/dev.d.ts CHANGED
@@ -10,8 +10,8 @@ export function startDev(devCommand: any, flags?: {}): Promise<{
10
10
  severityCode: number;
11
11
  logs: import("../log/logger.js").BufferedLogs | undefined;
12
12
  error: {
13
- message: any;
14
- stack: any;
13
+ message: string;
14
+ stack: string;
15
15
  };
16
16
  netlifyConfig?: undefined;
17
17
  configMutations?: undefined;
@@ -1,17 +1,2 @@
1
1
  import { ErrorParam } from '../core/types.js';
2
- export declare const handleBuildError: (error: Error, { errorMonitor, netlifyConfig, childEnv, logs, debug, testOpts }: ErrorParam) => Promise<{
3
- message: any;
4
- stack: any;
5
- errorProps: any;
6
- errorInfo: any;
7
- type: any;
8
- severity: any;
9
- title: any;
10
- group: any;
11
- stackType: any;
12
- locationType: any;
13
- showInBuildLog: any;
14
- showErrorProps: any;
15
- rawStack: any;
16
- errorMetadata: any;
17
- }>;
2
+ export declare const handleBuildError: (error: Error, { errorMonitor, netlifyConfig, childEnv, logs, debug, testOpts }: ErrorParam) => Promise<import("./types.js").BasicErrorInfo>;
@@ -1,6 +1,6 @@
1
- export function addDefaultErrorInfo(error: any, info: any): void;
2
- export function addErrorInfo(error: any, info: any): void;
3
- export function getErrorInfo(error: any): any[];
4
- export function changeErrorType(error: any, oldType: any, newType: any): void;
5
- export function isBuildError(error: any): boolean;
6
- export const CUSTOM_ERROR_KEY: "customErrorInfo";
1
+ export declare const addDefaultErrorInfo: (error: any, info: any) => void;
2
+ export declare const addErrorInfo: (error: any, info: any) => void;
3
+ export declare const getErrorInfo: (error: any) => any[];
4
+ export declare const changeErrorType: (error: any, oldType: any, newType: any) => void;
5
+ export declare const isBuildError: (error: any) => boolean;
6
+ export declare const CUSTOM_ERROR_KEY = "customErrorInfo";
@@ -1,5 +1,5 @@
1
- export function getLocationInfo({ stack, location, locationType }: {
1
+ export declare const getLocationInfo: ({ stack, location, locationType }: {
2
2
  stack: any;
3
3
  location: any;
4
4
  locationType: any;
5
- }): any;
5
+ }) => any;
@@ -1,39 +1,7 @@
1
- export function getFullErrorInfo({ error, colors, debug }: {
1
+ import type { BuildError, BasicErrorInfo } from '../types.js';
2
+ export declare const getFullErrorInfo: ({ error, colors, debug }: {
2
3
  error: any;
3
4
  colors: any;
4
5
  debug: any;
5
- }): {
6
- title: any;
7
- message: any;
8
- tsConfigInfo: any;
9
- pluginInfo: string | undefined;
10
- locationInfo: any;
11
- errorProps: string | undefined;
12
- errorMetadata: any;
13
- stack: any;
14
- errorInfo: any;
15
- type: any;
16
- severity: any;
17
- group: any;
18
- stackType: any;
19
- locationType: any;
20
- showInBuildLog: any;
21
- showErrorProps: any;
22
- rawStack: any;
23
- };
24
- export function parseErrorInfo(error: any): {
25
- message: any;
26
- stack: any;
27
- errorProps: any;
28
- errorInfo: any;
29
- type: any;
30
- severity: any;
31
- title: any;
32
- group: any;
33
- stackType: any;
34
- locationType: any;
35
- showInBuildLog: any;
36
- showErrorProps: any;
37
- rawStack: any;
38
- errorMetadata: any;
39
- };
6
+ }) => BuildError;
7
+ export declare const parseErrorInfo: (error: Error) => BasicErrorInfo;
@@ -1,6 +1,6 @@
1
1
  import { serializeObject } from '../../log/serialize.js';
2
2
  import { getErrorInfo } from '../info.js';
3
- import { getTypeInfo } from '../type.js';
3
+ import { getTypeInfo } from '../types.js';
4
4
  import { getLocationInfo } from './location.js';
5
5
  import { normalizeError } from './normalize.js';
6
6
  import { getPluginInfo } from './plugin.js';
@@ -9,9 +9,12 @@ import { getStackInfo } from './stack.js';
9
9
  // Add additional type-specific error information
10
10
  export const getFullErrorInfo = function ({ error, colors, debug }) {
11
11
  const basicErrorInfo = parseErrorInfo(error);
12
- const { message, stack, errorProps, errorInfo, errorInfo: { location = {}, plugin = {}, tsConfig }, severity, title, stackType, locationType, showErrorProps, rawStack, errorMetadata, } = basicErrorInfo;
12
+ const { message, stack, errorProps, errorInfo, severity, title, stackType, locationType, showErrorProps, rawStack, errorMetadata, } = basicErrorInfo;
13
+ const { location = {}, plugin = {}, tsConfig } = errorInfo;
13
14
  const titleA = getTitle(title, errorInfo);
14
15
  const { message: messageA, stack: stackA } = getStackInfo({ message, stack, stackType, rawStack, severity, debug });
16
+ // FIXME here location should be PluginLocation type, but I'm affraid to mess up the current
17
+ // getPluginInfo behaviour by running a type check
15
18
  const pluginInfo = getPluginInfo(plugin, location);
16
19
  const tsConfigInfo = getTsConfigInfo(tsConfig);
17
20
  const locationInfo = getLocationInfo({ stack: stackA, location, locationType });
@@ -1,9 +1,19 @@
1
- export function getPluginInfo({ pluginPackageJson }: {
1
+ export declare const getPluginInfo: ({ pluginPackageJson }: {
2
2
  pluginPackageJson?: {} | undefined;
3
3
  }, { packageName, loadedFrom }: {
4
4
  packageName: any;
5
5
  loadedFrom: any;
6
- }): string | undefined;
7
- export function getHomepage(pluginPackageJson?: {}, { loadedFrom }?: {
8
- loadedFrom: any;
9
- }): any;
6
+ }) => string | undefined;
7
+ type pkgJSONData = {
8
+ name?: string;
9
+ bugs?: {
10
+ url?: string;
11
+ };
12
+ repository?: {
13
+ url?: string;
14
+ };
15
+ };
16
+ export declare const getHomepage: (pluginPackageJson?: pkgJSONData, { loadedFrom }?: {
17
+ loadedFrom?: string | undefined;
18
+ }) => string | undefined;
19
+ export {};
@@ -19,7 +19,7 @@ const serializeField = function ({ name, getField, pluginPackageJson, packageNam
19
19
  return `${nameA}${field}`;
20
20
  };
21
21
  const NAME_PADDING = 16;
22
- const getPackage = function (pluginPackageJson, { packageName }) {
22
+ const getPackage = function (_, { packageName }) {
23
23
  return packageName;
24
24
  };
25
25
  const getVersion = function ({ version }) {
@@ -1,14 +1,7 @@
1
- export function serializeLogError({ fullErrorInfo: { title, severity, message, pluginInfo, locationInfo, tsConfigInfo, errorProps }, }: {
2
- fullErrorInfo: {
3
- title: any;
4
- severity: any;
5
- message: any;
6
- pluginInfo: any;
7
- locationInfo: any;
8
- tsConfigInfo: any;
9
- errorProps: any;
10
- };
11
- }): {
12
- title: any;
1
+ import type { BuildError } from '../types.js';
2
+ export declare const serializeLogError: ({ fullErrorInfo: { title, severity, message, pluginInfo, locationInfo, tsConfigInfo, errorProps }, }: {
3
+ fullErrorInfo: BuildError;
4
+ }) => {
5
+ title: string | (import("../types.js").TitleFunction & string);
13
6
  body: any;
14
7
  };
@@ -0,0 +1,174 @@
1
+ import { Attributes } from '@opentelemetry/api';
2
+ export type BuildError = Omit<BasicErrorInfo, 'errorProps'> & {
3
+ title: string;
4
+ pluginInfo?: string;
5
+ locationInfo?: string;
6
+ errorProps?: string;
7
+ };
8
+ export type BasicErrorInfo = {
9
+ message: string;
10
+ stack: string;
11
+ severity: string;
12
+ type: ErrorTypes;
13
+ errorInfo: ErrorInfo;
14
+ errorProps: Record<string, unknown>;
15
+ errorMetadata: any;
16
+ /**
17
+ * The core step id where the error took place
18
+ */
19
+ stage?: string;
20
+ tsConfigInfo?: any;
21
+ } & ErrorType;
22
+ /**
23
+ * Error severity groups the errors emitted by build and used to translate to exit code via SEVERITY_MAP
24
+ */
25
+ declare enum ErrorSeverity {
26
+ /**
27
+ * build success
28
+ */
29
+ success = "success",
30
+ /**
31
+ * not an error, e.g. build cancellation
32
+ */
33
+ none = "none",
34
+ /**
35
+ * user error
36
+ */
37
+ info = "info",
38
+ /**
39
+ * community plugin error
40
+ */
41
+ warning = "warning",
42
+ /**
43
+ * system error, including core plugin error
44
+ */
45
+ error = "Error"
46
+ }
47
+ /**
48
+ * How the stack trace should appear in the build error logs
49
+ */
50
+ declare enum StackType {
51
+ /**
52
+ * not printed
53
+ */
54
+ none = "none",
55
+ /**
56
+ * printed as is
57
+ */
58
+ stack = "stack",
59
+ /**
60
+ * printed as is, but taken from `error.message`. Used when `error.stack` is not being correct due to the error being passed between different processes.
61
+ */
62
+ message = "message"
63
+ }
64
+ type GroupFunction = ({ location }: {
65
+ location: ErrorLocation;
66
+ }) => string;
67
+ export type TitleFunction = ({ location }: {
68
+ location: ErrorLocation;
69
+ }) => string;
70
+ export type ErrorInfo = {
71
+ plugin?: any;
72
+ tsConfig?: any;
73
+ location: ErrorLocation;
74
+ };
75
+ export type BuildCommandLocation = {
76
+ buildCommand: string;
77
+ buildCommandOrigin: string;
78
+ };
79
+ export declare const isBuildCommandLocation: (location?: ErrorLocation) => location is BuildCommandLocation;
80
+ export type FunctionsBundlingLocation = {
81
+ functionName: string;
82
+ functionType: string;
83
+ };
84
+ export declare const isFunctionsBundlingLocation: (location?: ErrorLocation) => location is FunctionsBundlingLocation;
85
+ export type CoreStepLocation = {
86
+ coreStepName: string;
87
+ };
88
+ export declare const isCoreStepLocation: (location?: ErrorLocation) => location is CoreStepLocation;
89
+ export type PluginLocation = {
90
+ event: string;
91
+ packageName: string;
92
+ loadedFrom: string;
93
+ origin: string;
94
+ input?: string;
95
+ };
96
+ export declare const isPluginLocation: (location?: ErrorLocation) => location is PluginLocation;
97
+ export type APILocation = {
98
+ endpoint: string;
99
+ parameters?: any;
100
+ };
101
+ export declare const isAPILocation: (location?: ErrorLocation) => location is APILocation;
102
+ export type ErrorLocation = BuildCommandLocation | FunctionsBundlingLocation | CoreStepLocation | PluginLocation | APILocation;
103
+ /**
104
+ * Given a BuildError, extract the relevant trace attributes to add to the on-going Span
105
+ */
106
+ export declare const buildErrorToTracingAttributes: (error: BuildError | BasicErrorInfo) => Attributes;
107
+ /**
108
+ * Retrieve error-type specific information
109
+ */
110
+ export declare const getTypeInfo: ({ type }: {
111
+ type: any;
112
+ }) => any;
113
+ /**
114
+ * Interface for build error types
115
+ */
116
+ export interface ErrorType {
117
+ /**
118
+ * main title shown in build error logs and in the UI (statuses)
119
+ */
120
+ title: TitleFunction | string;
121
+ /**
122
+ * retrieve a human-friendly location of the error, printed
123
+ */
124
+ locationType?: string;
125
+ /**
126
+ * `true` when the `Error` instance static properties
127
+ */
128
+ showErrorProps?: boolean;
129
+ /**
130
+ * `true` when the stack trace should be cleaned up
131
+ */
132
+ rawStack?: boolean;
133
+ /**
134
+ * `true` when we want this error to show in build logs (defaults to true)
135
+ */
136
+ showInBuildLog?: boolean;
137
+ /**
138
+ * main title shown in Bugsnag. Also used to group errors together in Bugsnag, combined with `error.message`. Defaults to `title`.
139
+ */
140
+ group?: GroupFunction;
141
+ /**
142
+ * error severity (also used by Bugsnag)
143
+ */
144
+ severity: keyof typeof ErrorSeverity;
145
+ /**
146
+ * how the stack trace should appear in build error logs
147
+ */
148
+ stackType: keyof typeof StackType;
149
+ }
150
+ declare const ErrorTypeMap: {
151
+ /**
152
+ * Plugin called `utils.build.cancelBuild()`
153
+ */
154
+ readonly cancelBuild: "cancelBuild";
155
+ readonly resolveConfig: "resolveConfig";
156
+ readonly dependencies: "dependencies";
157
+ readonly pluginInput: "pluginInput";
158
+ readonly pluginUnsupportedVersion: "pluginUnsupportedVersion";
159
+ readonly buildCommand: "buildCommand";
160
+ readonly functionsBundling: "functionsBundling";
161
+ readonly secretScanningFoundSecrets: "secretScanningFoundSecrets";
162
+ readonly failPlugin: "failPlugin";
163
+ readonly failBuild: "failBuild";
164
+ readonly pluginValidation: "pluginValidation";
165
+ readonly pluginInternal: "pluginInternal";
166
+ readonly ipc: "ipc";
167
+ readonly corePlugin: "corePlugin";
168
+ readonly coreStep: "coreStep";
169
+ readonly api: "api";
170
+ readonly exception: "exception";
171
+ readonly telemetry: "telemetry";
172
+ };
173
+ type ErrorTypes = keyof typeof ErrorTypeMap;
174
+ export {};
@@ -0,0 +1,340 @@
1
+ /**
2
+ * Error severity groups the errors emitted by build and used to translate to exit code via SEVERITY_MAP
3
+ */
4
+ var ErrorSeverity;
5
+ (function (ErrorSeverity) {
6
+ /**
7
+ * build success
8
+ */
9
+ ErrorSeverity["success"] = "success";
10
+ /**
11
+ * not an error, e.g. build cancellation
12
+ */
13
+ ErrorSeverity["none"] = "none";
14
+ /**
15
+ * user error
16
+ */
17
+ ErrorSeverity["info"] = "info";
18
+ /**
19
+ * community plugin error
20
+ */
21
+ ErrorSeverity["warning"] = "warning";
22
+ /**
23
+ * system error, including core plugin error
24
+ */
25
+ ErrorSeverity["error"] = "Error";
26
+ })(ErrorSeverity || (ErrorSeverity = {}));
27
+ /**
28
+ * How the stack trace should appear in the build error logs
29
+ */
30
+ var StackType;
31
+ (function (StackType) {
32
+ /**
33
+ * not printed
34
+ */
35
+ StackType["none"] = "none";
36
+ /**
37
+ * printed as is
38
+ */
39
+ StackType["stack"] = "stack";
40
+ /**
41
+ * printed as is, but taken from `error.message`. Used when `error.stack` is not being correct due to the error being passed between different processes.
42
+ */
43
+ StackType["message"] = "message";
44
+ })(StackType || (StackType = {}));
45
+ export const isBuildCommandLocation = function (location) {
46
+ const buildLocation = location;
47
+ return typeof buildLocation?.buildCommand === 'string' && typeof buildLocation?.buildCommandOrigin === 'string';
48
+ };
49
+ export const isFunctionsBundlingLocation = function (location) {
50
+ const bundlingLocation = location;
51
+ return typeof bundlingLocation?.functionName === 'string' && typeof bundlingLocation?.functionType === 'string';
52
+ };
53
+ export const isCoreStepLocation = function (location) {
54
+ return typeof location?.coreStepName === 'string';
55
+ };
56
+ export const isPluginLocation = function (location) {
57
+ const pluginLocation = location;
58
+ return (typeof pluginLocation?.event === 'string' &&
59
+ typeof pluginLocation?.packageName === 'string' &&
60
+ typeof pluginLocation?.loadedFrom === 'string');
61
+ };
62
+ export const isAPILocation = function (location) {
63
+ return typeof location?.endpoint === 'string';
64
+ };
65
+ const buildErrorAttributePrefix = 'build.error';
66
+ const errorLocationToTracingAttributes = function (location) {
67
+ const locationAttributePrefix = `${buildErrorAttributePrefix}.location`;
68
+ if (isBuildCommandLocation(location)) {
69
+ return {
70
+ [`${locationAttributePrefix}.command`]: location.buildCommand,
71
+ [`${locationAttributePrefix}.command_origin`]: location.buildCommandOrigin,
72
+ };
73
+ }
74
+ if (isPluginLocation(location)) {
75
+ return {
76
+ [`${locationAttributePrefix}.plugin.event`]: location.event,
77
+ [`${locationAttributePrefix}.plugin.package_name`]: location.packageName,
78
+ [`${locationAttributePrefix}.plugin.loaded_from`]: location.loadedFrom,
79
+ [`${locationAttributePrefix}.plugin.origin`]: location.origin,
80
+ };
81
+ }
82
+ if (isFunctionsBundlingLocation(location)) {
83
+ return {
84
+ [`${locationAttributePrefix}.function.type`]: location.functionType,
85
+ [`${locationAttributePrefix}.function.name`]: location.functionName,
86
+ };
87
+ }
88
+ if (isCoreStepLocation(location)) {
89
+ return {
90
+ [`${locationAttributePrefix}.core_step.name`]: location.coreStepName,
91
+ };
92
+ }
93
+ if (isAPILocation(location)) {
94
+ return {
95
+ [`${locationAttributePrefix}.api.endpoint`]: location.endpoint,
96
+ };
97
+ }
98
+ return {};
99
+ };
100
+ /**
101
+ * Given a BuildError, extract the relevant trace attributes to add to the on-going Span
102
+ */
103
+ export const buildErrorToTracingAttributes = function (error) {
104
+ const attributes = {};
105
+ // Check we're not adding undefined values
106
+ if (error?.severity)
107
+ attributes[`${buildErrorAttributePrefix}.severity`] = error.severity;
108
+ if (error?.type)
109
+ attributes[`${buildErrorAttributePrefix}.type`] = error.type;
110
+ if (error?.locationType)
111
+ attributes[`${buildErrorAttributePrefix}.location.type`] = error.locationType;
112
+ if (error?.stage)
113
+ attributes[`${buildErrorAttributePrefix}.step.id`] = error.stage;
114
+ return {
115
+ ...attributes,
116
+ ...errorLocationToTracingAttributes(error.errorInfo?.location),
117
+ };
118
+ };
119
+ /**
120
+ * Retrieve error-type specific information
121
+ */
122
+ export const getTypeInfo = function ({ type }) {
123
+ const typeA = TYPES[type] === undefined ? DEFAULT_TYPE : type;
124
+ return { type: typeA, ...TYPES[typeA] };
125
+ };
126
+ const ErrorTypeMap = {
127
+ /**
128
+ * Plugin called `utils.build.cancelBuild()`
129
+ */
130
+ cancelBuild: 'cancelBuild',
131
+ resolveConfig: 'resolveConfig',
132
+ dependencies: 'dependencies',
133
+ pluginInput: 'pluginInput',
134
+ pluginUnsupportedVersion: 'pluginUnsupportedVersion',
135
+ buildCommand: 'buildCommand',
136
+ functionsBundling: 'functionsBundling',
137
+ secretScanningFoundSecrets: 'secretScanningFoundSecrets',
138
+ failPlugin: 'failPlugin',
139
+ failBuild: 'failBuild',
140
+ pluginValidation: 'pluginValidation',
141
+ pluginInternal: 'pluginInternal',
142
+ ipc: 'ipc',
143
+ corePlugin: 'corePlugin',
144
+ coreStep: 'coreStep',
145
+ api: 'api',
146
+ exception: 'exception',
147
+ telemetry: 'telemetry',
148
+ };
149
+ /**
150
+ * List of error types, and their related properties
151
+ * New error types should be added to Bugsnag since we use it for automated
152
+ * monitoring (through its Slack integration). The steps in Bugsnag are:
153
+ * - Create a new bookmark. Try to re-use the search filter of an existing
154
+ * bookmark with a similar error type, but only changing the `errorClass`.
155
+ * Make sure to check the box "Share with my team".
156
+ * - Add the `errorClass` to the search filter of either the "All warnings" or
157
+ * "All errors" bookmark depending on whether we should get notified on Slack
158
+ * for new errors of that type. You must use the bookmark menu action "Update
159
+ * with current filters"
160
+ *
161
+ */
162
+ const TYPES = {
163
+ /**
164
+ * Plugin called `utils.build.cancelBuild()`
165
+ */
166
+ cancelBuild: {
167
+ title: ({ location: { packageName } }) => `Build canceled by ${packageName}`,
168
+ stackType: 'stack',
169
+ locationType: 'buildFail',
170
+ severity: 'none',
171
+ },
172
+ /**
173
+ * User configuration error (`@netlify/config`, wrong Node.js version)
174
+ */
175
+ resolveConfig: {
176
+ title: 'Configuration error',
177
+ stackType: 'none',
178
+ severity: 'info',
179
+ },
180
+ /**
181
+ * Error while installing user packages (missing plugins, local plugins or functions dependencies)
182
+ */
183
+ dependencies: {
184
+ title: 'Dependencies installation error',
185
+ stackType: 'none',
186
+ severity: 'info',
187
+ },
188
+ /**
189
+ * User misconfigured a plugin
190
+ */
191
+ pluginInput: {
192
+ title: ({ location: { packageName, input } }) => `Plugin "${packageName}" invalid input "${input}"`,
193
+ stackType: 'none',
194
+ locationType: 'buildFail',
195
+ severity: 'info',
196
+ },
197
+ /**
198
+ * User package.json sets an unsupported plugin version
199
+ */
200
+ pluginUnsupportedVersion: {
201
+ title: 'Unsupported plugin version detected',
202
+ stackType: 'none',
203
+ severity: 'info',
204
+ },
205
+ /**
206
+ * `build.command` non-0 exit code
207
+ */
208
+ buildCommand: {
209
+ title: '"build.command" failed',
210
+ group: ({ location: { buildCommand } }) => buildCommand,
211
+ stackType: 'message',
212
+ locationType: 'buildCommand',
213
+ severity: 'info',
214
+ },
215
+ /**
216
+ * User error during Functions bundling
217
+ */
218
+ functionsBundling: {
219
+ title: ({ location: { functionName, functionType } }) => {
220
+ if (functionType === 'edge') {
221
+ return 'Bundling of edge function failed';
222
+ }
223
+ return `Bundling of function "${functionName}" failed`;
224
+ },
225
+ group: ({ location: { functionType = 'serverless' } }) => `Bundling of ${functionType} function failed`,
226
+ stackType: 'none',
227
+ locationType: 'functionsBundling',
228
+ severity: 'info',
229
+ },
230
+ /**
231
+ * Error from the secret scanning core step
232
+ */
233
+ secretScanningFoundSecrets: {
234
+ title: 'Secrets scanning detected secrets in files during build.',
235
+ stackType: 'none',
236
+ severity: 'info',
237
+ },
238
+ /**
239
+ * Plugin called `utils.build.failBuild()`
240
+ */
241
+ failBuild: {
242
+ title: ({ location: { packageName } }) => `Plugin "${packageName}" failed`,
243
+ stackType: 'stack',
244
+ locationType: 'buildFail',
245
+ severity: 'info',
246
+ },
247
+ /**
248
+ * Plugin called `utils.build.failPlugin()`
249
+ */
250
+ failPlugin: {
251
+ title: ({ location: { packageName } }) => `Plugin "${packageName}" failed`,
252
+ stackType: 'stack',
253
+ locationType: 'buildFail',
254
+ severity: 'info',
255
+ },
256
+ /**
257
+ * Plugin has an invalid shape
258
+ */
259
+ pluginValidation: {
260
+ title: ({ location: { packageName } }) => `Plugin "${packageName}" internal error`,
261
+ stackType: 'stack',
262
+ locationType: 'buildFail',
263
+ severity: 'warning',
264
+ },
265
+ /**
266
+ * Plugin threw an uncaught exception
267
+ */
268
+ pluginInternal: {
269
+ title: ({ location: { packageName } }) => `Plugin "${packageName}" internal error`,
270
+ stackType: 'stack',
271
+ showErrorProps: true,
272
+ rawStack: true,
273
+ locationType: 'buildFail',
274
+ severity: 'warning',
275
+ },
276
+ /**
277
+ * Bug while orchestrating child processes
278
+ */
279
+ ipc: {
280
+ title: ({ location: { packageName } }) => `Plugin "${packageName}" internal error`,
281
+ stackType: 'none',
282
+ locationType: 'buildFail',
283
+ severity: 'warning',
284
+ },
285
+ /**
286
+ * Core plugin internal error
287
+ */
288
+ corePlugin: {
289
+ title: ({ location: { packageName } }) => `Plugin "${packageName}" internal error`,
290
+ stackType: 'stack',
291
+ showErrorProps: true,
292
+ rawStack: true,
293
+ locationType: 'buildFail',
294
+ severity: 'error',
295
+ },
296
+ /**
297
+ * Core step internal error
298
+ */
299
+ coreStep: {
300
+ title: ({ location: { coreStepName } }) => `Internal error during "${coreStepName}"`,
301
+ stackType: 'stack',
302
+ showErrorProps: true,
303
+ rawStack: true,
304
+ locationType: 'coreStep',
305
+ severity: 'error',
306
+ },
307
+ /**
308
+ * Request error when `@netlify/build` was calling Netlify API
309
+ */
310
+ api: {
311
+ title: ({ location: { endpoint } }) => `API error on "${endpoint}"`,
312
+ stackType: 'message',
313
+ showErrorProps: true,
314
+ locationType: 'api',
315
+ severity: 'error',
316
+ },
317
+ /**
318
+ * `@netlify/build` threw an uncaught exception
319
+ */
320
+ exception: {
321
+ title: 'Core internal error',
322
+ stackType: 'stack',
323
+ showErrorProps: true,
324
+ rawStack: true,
325
+ severity: 'error',
326
+ },
327
+ /**
328
+ * Errors related with the telemetry output
329
+ */
330
+ telemetry: {
331
+ showInBuildLog: false,
332
+ title: 'Telemetry error',
333
+ stackType: 'stack',
334
+ showErrorProps: true,
335
+ rawStack: true,
336
+ severity: 'error',
337
+ },
338
+ };
339
+ // When no error type matches, it's an uncaught exception, i.e. a bug
340
+ const DEFAULT_TYPE = 'exception';
@@ -93,5 +93,5 @@ export const logSecretsScanFailBuildMessage = function ({ logs, scanResults, gro
93
93
  });
94
94
  logError(logs, `\nTo prevent exposing secrets, the build will fail until these secret values are not found in build output or repo files.`);
95
95
  logError(logs, `If these are expected, use SECRETS_SCAN_OMIT_PATHS, SECRETS_SCAN_OMIT_KEYS, or SECRETS_SCAN_ENABLED to prevent detecting.`);
96
- logError(logs, `See the Netlify Docs for more information on secrets scanning.`);
96
+ logError(logs, `For more information on secrets scanning, see the Netlify Docs: https://ntl.fyi/configure-secrets-scanning`);
97
97
  };
@@ -4,6 +4,7 @@ import { context, trace, propagation, SpanStatusCode, diag, DiagLogLevel } from
4
4
  import { parseKeyPairsIntoRecord } from '@opentelemetry/core/build/src/baggage/utils.js';
5
5
  import { isBuildError } from '../error/info.js';
6
6
  import { parseErrorInfo } from '../error/parse/parse.js';
7
+ import { buildErrorToTracingAttributes } from '../error/types.js';
7
8
  import { ROOT_PACKAGE_JSON } from '../utils/json.js';
8
9
  let sdk;
9
10
  /** Given a simple logging function return a `DiagLogger`. Used to setup our system logger as the diag logger.*/
@@ -82,10 +83,10 @@ export const addErrorToActiveSpan = function (error) {
82
83
  if (!span)
83
84
  return;
84
85
  if (isBuildError(error)) {
85
- const { severity, type } = parseErrorInfo(error);
86
- if (severity == 'none')
86
+ const buildError = parseErrorInfo(error);
87
+ if (buildError.severity == 'none')
87
88
  return;
88
- span.setAttributes({ severity, type });
89
+ span.setAttributes(buildErrorToTracingAttributes(buildError));
89
90
  }
90
91
  span.recordException(error);
91
92
  span.setStatus({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/build",
3
- "version": "29.26.3",
3
+ "version": "29.26.5",
4
4
  "description": "Netlify build module",
5
5
  "type": "module",
6
6
  "exports": "./lib/index.js",
@@ -67,8 +67,8 @@
67
67
  "@bugsnag/js": "^7.0.0",
68
68
  "@honeycombio/opentelemetry-node": "^0.5.0",
69
69
  "@netlify/cache-utils": "^5.1.5",
70
- "@netlify/config": "^20.9.0",
71
- "@netlify/edge-bundler": "10.1.0",
70
+ "@netlify/config": "^20.10.0",
71
+ "@netlify/edge-bundler": "10.1.1",
72
72
  "@netlify/framework-info": "^9.8.10",
73
73
  "@netlify/functions-utils": "^5.2.40",
74
74
  "@netlify/git-utils": "^5.1.1",
@@ -146,5 +146,5 @@
146
146
  "engines": {
147
147
  "node": "^14.16.0 || >=16.0.0"
148
148
  },
149
- "gitHead": "fd75258a36e9e47aeed8d1099f6c9f87d2957328"
149
+ "gitHead": "01ca6c705c4b568b7552a7d90a9801ebdc747594"
150
150
  }
@@ -1,3 +0,0 @@
1
- export function getTypeInfo({ type }: {
2
- type: any;
3
- }): any;
package/lib/error/type.js DELETED
@@ -1,182 +0,0 @@
1
- // Retrieve error-type specific information
2
- export const getTypeInfo = function ({ type }) {
3
- const typeA = TYPES[type] === undefined ? DEFAULT_TYPE : type;
4
- return { type: typeA, ...TYPES[typeA] };
5
- };
6
- // List of error types, and their related properties
7
- // Related to build error logs:
8
- // - `showInBuildLog`: `true` when we want this error to show in build logs (defaults to true)
9
- // - `title`: main title shown in build error logs and in the UI (statuses)
10
- // - `locationType`: retrieve a human-friendly location of the error, printed
11
- // in build error logs
12
- // - `showErrorProps`: `true` when the `Error` instance static properties
13
- // should be printed in build error logs. Only useful when the `Error`
14
- // instance was not created by us.
15
- // - `rawStack`: `true` when the stack trace should be cleaned up
16
- // - `stackType`: how the stack trace should appear in build error logs:
17
- // - `none`: not printed
18
- // - `stack`: printed as is
19
- // - `message`: printed as is, but taken from `error.message`.
20
- // Used when `error.stack` is not being correct due to the error being
21
- // passed between different processes.
22
- // - `severity`: error severity (also used by Bugsnag):
23
- // - `success`: build success
24
- // - `none`: not an error, e.g. build cancellation
25
- // - `info`: user error
26
- // - `warning`: community plugin error
27
- // - `error`: system error, including core plugin error
28
- // Related to Bugsnag:
29
- // - `group`: main title shown in Bugsnag. Also used to group errors together
30
- // in Bugsnag, combined with `error.message`.
31
- // Defaults to `title`.
32
- // New error types should be added to Bugsnag since we use it for automated
33
- // monitoring (through its Slack integration). The steps in Bugsnag are:
34
- // - Create a new bookmark. Try to re-use the search filter of an existing
35
- // bookmark with a similar error type, but only changing the `errorClass`.
36
- // Make sure to check the box "Share with my team".
37
- // - Add the `errorClass` to the search filter of either the "All warnings" or
38
- // "All errors" bookmark depending on whether we should get notified on Slack
39
- // for new errors of that type. You must use the bookmark menu action "Update
40
- // with current filters"
41
- const TYPES = {
42
- // Plugin called `utils.build.cancelBuild()`
43
- cancelBuild: {
44
- title: ({ location: { packageName } }) => `Build canceled by ${packageName}`,
45
- stackType: 'stack',
46
- locationType: 'buildFail',
47
- severity: 'none',
48
- },
49
- // User configuration error (`@netlify/config`, wrong Node.js version)
50
- resolveConfig: {
51
- title: 'Configuration error',
52
- stackType: 'none',
53
- severity: 'info',
54
- },
55
- // Error while installing user packages (missing plugins, local plugins or functions dependencies)
56
- dependencies: {
57
- title: 'Dependencies installation error',
58
- stackType: 'none',
59
- severity: 'info',
60
- },
61
- // User misconfigured a plugin
62
- pluginInput: {
63
- title: ({ location: { packageName, input } }) => `Plugin "${packageName}" invalid input "${input}"`,
64
- stackType: 'none',
65
- locationType: 'buildFail',
66
- severity: 'info',
67
- },
68
- // User package.json sets an unsupported plugin version
69
- pluginUnsupportedVersion: {
70
- title: 'Unsupported plugin version detected',
71
- stackType: 'none',
72
- severity: 'info',
73
- },
74
- // `build.command` non-0 exit code
75
- buildCommand: {
76
- title: '"build.command" failed',
77
- group: ({ location: { buildCommand } }) => buildCommand,
78
- stackType: 'message',
79
- locationType: 'buildCommand',
80
- severity: 'info',
81
- },
82
- // User error during Functions bundling
83
- functionsBundling: {
84
- title: ({ location: { functionName, functionType } }) => {
85
- if (functionType === 'edge') {
86
- return 'Bundling of edge function failed';
87
- }
88
- return `Bundling of function "${functionName}" failed`;
89
- },
90
- group: ({ location: { functionType = 'serverless' } }) => `Bundling of ${functionType} function failed`,
91
- stackType: 'none',
92
- locationType: 'functionsBundling',
93
- severity: 'info',
94
- },
95
- secretScanningFoundSecrets: {
96
- title: 'Secrets scanning detected secrets in files during build.',
97
- stackType: 'none',
98
- severity: 'info',
99
- },
100
- // Plugin called `utils.build.failBuild()`
101
- failBuild: {
102
- title: ({ location: { packageName } }) => `Plugin "${packageName}" failed`,
103
- stackType: 'stack',
104
- locationType: 'buildFail',
105
- severity: 'info',
106
- },
107
- // Plugin called `utils.build.failPlugin()`
108
- failPlugin: {
109
- title: ({ location: { packageName } }) => `Plugin "${packageName}" failed`,
110
- stackType: 'stack',
111
- locationType: 'buildFail',
112
- severity: 'info',
113
- },
114
- // Plugin has an invalid shape
115
- pluginValidation: {
116
- title: ({ location: { packageName } }) => `Plugin "${packageName}" internal error`,
117
- stackType: 'stack',
118
- locationType: 'buildFail',
119
- severity: 'warning',
120
- },
121
- // Plugin threw an uncaught exception
122
- pluginInternal: {
123
- title: ({ location: { packageName } }) => `Plugin "${packageName}" internal error`,
124
- stackType: 'stack',
125
- showErrorProps: true,
126
- rawStack: true,
127
- locationType: 'buildFail',
128
- severity: 'warning',
129
- },
130
- // Bug while orchestrating child processes
131
- ipc: {
132
- title: ({ location: { packageName } }) => `Plugin "${packageName}" internal error`,
133
- stackType: 'none',
134
- locationType: 'buildFail',
135
- severity: 'warning',
136
- },
137
- // Core plugin internal error
138
- corePlugin: {
139
- title: ({ location: { packageName } }) => `Plugin "${packageName}" internal error`,
140
- stackType: 'stack',
141
- showErrorProps: true,
142
- rawStack: true,
143
- locationType: 'buildFail',
144
- severity: 'error',
145
- },
146
- // Core step internal error
147
- coreStep: {
148
- title: ({ location: { coreStepName } }) => `Internal error during "${coreStepName}"`,
149
- stackType: 'stack',
150
- showErrorProps: true,
151
- rawStack: true,
152
- locationType: 'coreStep',
153
- severity: 'error',
154
- },
155
- // Request error when `@netlify/build` was calling Netlify API
156
- api: {
157
- title: ({ location: { endpoint } }) => `API error on "${endpoint}"`,
158
- stackType: 'message',
159
- showErrorProps: true,
160
- locationType: 'api',
161
- severity: 'error',
162
- },
163
- // `@netlify/build` threw an uncaught exception
164
- exception: {
165
- title: 'Core internal error',
166
- stackType: 'stack',
167
- showErrorProps: true,
168
- rawStack: true,
169
- severity: 'error',
170
- },
171
- // Errors related with the telemetry output
172
- telemetry: {
173
- showInBuildLog: false,
174
- title: 'Telemetry error',
175
- stackType: 'stack',
176
- showErrorProps: true,
177
- rawStack: true,
178
- severity: 'error',
179
- },
180
- };
181
- // When no error type matches, it's an uncaught exception, i.e. a bug
182
- const DEFAULT_TYPE = 'exception';