/
error-map.ts
1003 lines (970 loc) · 37.7 KB
/
error-map.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import { stripIndent, stripIndents } from "common-tags"
import {
IOptionalGraphQLInfoContext,
Level,
Type,
ErrorCategory,
} from "./types"
const optionalGraphQLInfo = (context: IOptionalGraphQLInfoContext): string =>
`${context.codeFrame ? `\n\n${context.codeFrame}` : ``}${
context.filePath ? `\n\nFile path: ${context.filePath}` : ``
}${context.urlPath ? `\nUrl path: ${context.urlPath}` : ``}${
context.plugin ? `\nPlugin: ${context.plugin}` : ``
}`
const getSharedNodeManifestWarning = (inputManifest: {
manifestId: string
node: { id: string }
pluginName: string
}): string =>
`Plugin ${inputManifest.pluginName} called unstable_createNodeManifest() for node id "${inputManifest.node.id}" with a manifest id of "${inputManifest.manifestId}"`
const errors: Record<string, IErrorMapEntry> = {
"": {
text: (context): string => {
const sourceMessage =
context && context.sourceMessage
? context.sourceMessage
: `There was an unhandled error and we could not retrieve more information. Please run the command with the --verbose flag again.`
return sourceMessage
},
level: Level.ERROR,
category: ErrorCategory.UNKNOWN,
type: Type.UNKNOWN,
},
"95312": {
text: (context): string =>
`"${context.undefinedGlobal}" is not available during server-side rendering. Enable "DEV_SSR" to debug this during "gatsby develop".`,
level: Level.ERROR,
docsUrl: `https://gatsby.dev/debug-html`,
category: ErrorCategory.USER,
type: Type.HTML_COMPILATION,
},
"95313": {
text: (context): string =>
`Building static HTML failed${
context.errorPath ? ` for path "${context.errorPath}"` : ``
}`,
level: Level.ERROR,
docsUrl: `https://gatsby.dev/debug-html`,
category: ErrorCategory.UNKNOWN,
type: Type.HTML_COMPILATION,
},
"95314": {
text: (context): string => context.errorMessage,
level: Level.ERROR,
docsUrl: `https://gatsby.dev/debug-html`,
type: Type.HTML_COMPILATION,
category: ErrorCategory.UNKNOWN,
},
"95315": {
text: (context): string =>
`Error in getServerData in ${context.pagePath} / "${context.potentialPagePath}".`,
level: Level.ERROR,
category: ErrorCategory.USER,
type: Type.ENGINE_EXECUTION,
},
"98001": {
text: (): string =>
`Built Rendering Engines failed validation.\n\nPlease open an issue with a reproduction at https://gatsby.dev/new-issue for more help.`,
type: Type.ENGINE_VALIDATION,
level: Level.ERROR,
category: ErrorCategory.UNKNOWN,
},
"98011": {
text: (context): string =>
`Rendering Engines attempted to use unsupported "${
context.package
}" package${
context.importedBy ? ` (imported by "${context.importedBy}")` : ``
}${context.advisory ? `\n\n${context.advisory}` : ``}`,
type: Type.ENGINE_COMPILATION,
level: Level.ERROR,
category: ErrorCategory.USER,
},
"98051": {
text: (): string => `Built Rendering Engines failed to load.`,
type: Type.ENGINE_EXECUTION,
level: Level.ERROR,
category: ErrorCategory.UNKNOWN,
},
"98123": {
text: (context): string =>
`${context.stageLabel} failed\n\n${
context.sourceMessage ?? context.message
}`,
type: (context): `${Type}` =>
`WEBPACK.${
context.stage.toUpperCase() as
| `DEVELOP`
| `DEVELOP-HTML`
| `BUILD-JAVASCRIPT`
| `BUILD-HTML`
}`,
level: Level.ERROR,
category: ErrorCategory.UNKNOWN,
},
"98124": {
text: (context): string => {
let message = `${context.stageLabel} failed\n\n${context.sourceMessage}\n\nIf you're trying to use a package make sure that '${context.packageName}' is installed. If you're trying to use a local file make sure that the path is correct.`
if (context.deprecationReason) {
message += `\n\n${context.deprecationReason}`
}
return message
},
type: (context): `${Type}` =>
`WEBPACK.${
context.stage.toUpperCase() as
| `DEVELOP`
| `DEVELOP-HTML`
| `BUILD-JAVASCRIPT`
| `BUILD-HTML`
}`,
level: Level.ERROR,
category: ErrorCategory.USER,
},
"85901": {
text: (context): string =>
stripIndent(`
There was an error in your GraphQL query:\n\n${
context.sourceMessage
}${optionalGraphQLInfo(context)}`),
type: Type.GRAPHQL_UNKNOWN,
level: Level.ERROR,
category: ErrorCategory.USER,
},
"85908": {
text: (context): string => {
const closestFragment = context.closestFragment
? `\n\nDid you mean to use ` + `"${context.closestFragment}"?`
: ``
return `There was an error in your GraphQL query:\n\nThe fragment "${context.fragmentName}" does not exist.\n\n${context.codeFrame}${closestFragment}`
},
type: Type.GRAPHQL_VALIDATION,
level: Level.ERROR,
category: ErrorCategory.USER,
},
"85910": {
text: (context): string =>
stripIndents(`
Multiple "root" queries found: "${context.name}" and "${context.otherName}".
Only the first ("${context.otherName}") will be registered.
Instead of:
${context.beforeCodeFrame}
Do:
${context.afterCodeFrame}
This can happen when you use two page/static queries in one file. Please combine those into one query.
If you're defining multiple components (each with a static query) in one file, you'll need to move each component to its own file.
`),
type: Type.GRAPHQL_VALIDATION,
level: Level.ERROR,
docsUrl: `https://www.gatsbyjs.com/docs/how-to/querying-data/`,
category: ErrorCategory.USER,
},
"85911": {
text: (context): string =>
stripIndent(`
There was a problem parsing "${context.filePath}"; any GraphQL
fragments or queries in this file were not processed.
This may indicate a syntax error in the code, or it may be a file type
that Gatsby does not know how to parse.
`),
type: Type.GRAPHQL_EXTRACTION,
level: Level.ERROR,
category: ErrorCategory.USER,
},
"85912": {
text: (context): string =>
`Failed to parse preprocessed file ${context.filePath}`,
type: Type.GRAPHQL_EXTRACTION,
level: Level.ERROR,
category: ErrorCategory.UNKNOWN,
},
"85913": {
text: (context): string =>
`There was a problem reading the file: ${context.filePath}`,
type: Type.GRAPHQL_EXTRACTION,
level: Level.ERROR,
category: ErrorCategory.UNKNOWN,
},
// default parsing error
"85915": {
text: (context): string =>
`There was a problem parsing the GraphQL query in file: ${context.filePath}`,
type: Type.GRAPHQL_EXTRACTION,
level: Level.ERROR,
category: ErrorCategory.USER,
},
"85916": {
text: (context): string =>
`String interpolation is not allowed in graphql tag:\n\n${context.codeFrame}`,
type: Type.GRAPHQL_VALIDATION,
level: Level.ERROR,
category: ErrorCategory.USER,
},
"85917": {
text: (context): string =>
`Unexpected empty graphql tag${
context.codeFrame ? `\n\n${context.codeFrame}` : ``
}`,
type: Type.GRAPHQL_VALIDATION,
level: Level.ERROR,
category: ErrorCategory.USER,
},
"85918": {
text: (context): string =>
stripIndent(`
GraphQL syntax error in query:\n\n${context.sourceMessage}${
context.codeFrame ? `\n\n${context.codeFrame}` : ``
}`),
type: Type.GRAPHQL_VALIDATION,
level: Level.ERROR,
category: ErrorCategory.USER,
},
// Duplicate fragment
"85919": {
text: (context): string =>
stripIndent(`
Found two different GraphQL fragments with identical name "${context.fragmentName}". Fragment names must be unique
File: ${context.leftFragment.filePath}
${context.leftFragment.codeFrame}
File: ${context.rightFragment.filePath}
${context.rightFragment.codeFrame}
`),
type: Type.GRAPHQL_VALIDATION,
level: Level.ERROR,
category: ErrorCategory.USER,
},
// Undefined variables in Queries
"85920": {
text: (context): string => {
const staticQueryMessage = stripIndents(`Suggestion 1:
If you're not using a page query but useStaticQuery you see this error because it doesn't support variables. To learn more about the limitations: https://gatsby.dev/use-static-query`)
const generalMessage = stripIndents(`Suggestion 2:
You might have a typo in the variable name "${context.variableName}" or you didn't provide the variable via context to this page query. Learn how to add data to context: https://gatsby.dev/graphql-variables-how-to`)
return stripIndent(`
There was an error in your GraphQL query:\n\n${
context.sourceMessage
}${optionalGraphQLInfo(
context
)}\n\n${staticQueryMessage}\n\n${generalMessage}`)
},
type: Type.GRAPHQL_VALIDATION,
level: Level.ERROR,
category: ErrorCategory.USER,
},
"85921": {
text: (context): string =>
`There was an error in your GraphQL query:\n\n${context.sourceMessage}\n\nIf you're e.g. filtering for specific nodes make sure that you choose the correct field (that has the same type "${context.inputType}") or adjust the context variable to the type "${context.expectedType}".`,
type: Type.GRAPHQL_VALIDATION,
level: Level.ERROR,
category: ErrorCategory.USER,
},
"85922": {
text: (context): string =>
`There was an error in your GraphQL query:
${context.sourceMessage}
This can happen if you e.g. accidentally added { } to the field "${context.fieldName}". If you didn't expect "${context.fieldName}" to be of type "${context.fieldType}" make sure that your input source and/or plugin is correct.
However, if you expect "${context.fieldName}" to exist, the field might be accessible in another subfield. Please try your query in GraphiQL.
It is recommended to explicitly type your GraphQL schema if you want to use optional fields.`,
type: Type.GRAPHQL_VALIDATION,
level: Level.ERROR,
category: ErrorCategory.USER,
docsUrl: `https://gatsby.dev/creating-type-definitions`,
},
"85923": {
text: (context): string =>
`There was an error in your GraphQL query:\n\n${context.sourceMessage}\n\nIf you don't expect "${context.field}" to exist on the type "${context.type}" it is most likely a typo. However, if you expect "${context.field}" to exist there are a couple of solutions to common problems:\n\n- If you added a new data source and/or changed something inside gatsby-node/gatsby-config, please try a restart of your development server.\n- You want to optionally use your field "${context.field}" and right now it is not used anywhere.\n\nIt is recommended to explicitly type your GraphQL schema if you want to use optional fields.`,
type: Type.GRAPHQL_VALIDATION,
level: Level.ERROR,
category: ErrorCategory.USER,
docsUrl: `https://gatsby.dev/creating-type-definitions`,
},
"85924": {
text: (context): string =>
`There was an error in your GraphQL query:\n\n${
context.sourceMessage
}\n\nThis can happen when you or a plugin/theme explicitly defined the GraphQL schema for this GraphQL object type via the schema customization API and "${
context.value
}" doesn't match the (scalar) type of "${
context.type
}".${optionalGraphQLInfo(context)}`,
type: Type.GRAPHQL_VALIDATION,
level: Level.ERROR,
category: ErrorCategory.USER,
},
"85925": {
text: (context): string =>
`There was an error in your GraphQL query:\n\n${
context.sourceMessage
}\n\nThe field "${
context.field
}" was explicitly defined as non-nullable via the schema customization API (by yourself or a plugin/theme). This means that this field is not optional and you have to define a value. If this is not your desired behavior and you defined the schema yourself, go to "createTypes" in gatsby-node.${optionalGraphQLInfo(
context
)}`,
type: Type.GRAPHQL_VALIDATION,
level: Level.ERROR,
category: ErrorCategory.USER,
docsUrl: `https://gatsby.dev/creating-type-definitions`,
},
"85926": {
text: (context): string =>
`There was an error in your GraphQL query:\n\n${context.sourceMessage}\n\nThis can happen when you use graphql\`{ ...yourQuery }\` instead of graphql(\`{ ...yourQuery }\`) inside gatsby-node\n\nYou can't use the template literal function you're used to (from page queries) and rather have to call graphql() as a normal function.`,
type: Type.GRAPHQL_VALIDATION,
level: Level.ERROR,
category: ErrorCategory.USER,
},
"85927": {
text: (context): string =>
`There was an error in your GraphQL query:\n\n${context.sourceMessage}\n\nSee if "${context.variable}" has a typo or ${context.operation} doesn't actually require this variable.`,
type: Type.GRAPHQL_VALIDATION,
level: Level.ERROR,
category: ErrorCategory.USER,
},
"85928": {
text: (): string =>
`An error occurred during parallel query running.\nGo here for troubleshooting tips: https://gatsby.dev/pqr-feedback`,
level: Level.ERROR,
category: ErrorCategory.UNKNOWN,
type: Type.GRAPHQL_QUERY_RUNNING,
},
"85929": {
text: (context): string =>
`The "${context.exportName}" export must be async when using it with graphql:\n\n${context.codeFrame}`,
type: Type.GRAPHQL_EXTRACTION,
level: Level.ERROR,
category: ErrorCategory.USER,
},
// Config errors
"10122": {
text: (context): string =>
`The site's gatsby-config failed validation:\n\n${context.sourceMessage}`,
type: Type.API_CONFIG_VALIDATION,
level: Level.ERROR,
category: ErrorCategory.USER,
},
"10123": {
text: (context): string =>
`We encountered an error while trying to load your site's ${context.configName}. Please fix the error and try again.`,
type: Type.API_CONFIG_LOADING,
level: Level.ERROR,
category: ErrorCategory.USER,
},
"10124": {
text: (context): string =>
`It looks like you were trying to add the config file? Please rename "${
context.nearMatch
}" to "${context.configName}.${context.isTSX ? `ts` : `js`}"`,
type: Type.API_CONFIG_LOADING,
// TODO: Make this a warning? Needs to be also changed where this error is called + tests
level: Level.ERROR,
category: ErrorCategory.USER,
},
"10125": {
text: (context): string =>
`Your ${context.configName} file is in the wrong place. You've placed it in the src/ directory. It must instead be at the root of your site next to your package.json file.`,
type: Type.API_CONFIG_LOADING,
// TODO: Make this a warning? Needs to be also changed where this error is called + tests
level: Level.ERROR,
category: ErrorCategory.USER,
},
"10126": {
text: (context): string =>
`${context.path}/${context.configName} cannot export a function.` +
`\n\nA ${context.configName} exported as a function can only be used as a theme and not run directly.` +
`\nIf you are trying to run a theme directly, use the theme in an example site or starter instead and run that site to test.` +
`\nIf you are in the root gatsby-config for your site, change the export to be an object and not a function as functions` +
`\nare not supported in the root gatsby-config.`,
type: Type.API_CONFIG_LOADING,
level: Level.ERROR,
category: ErrorCategory.USER,
},
"10127": {
text: (context): string =>
`Your "${context.configName}.ts" file failed to compile to "${context.configName}.js". Please run "gatsby clean" and try again.\n\nIf the issue persists, please open an issue with a reproduction at https://gatsby.dev/new-issue for more help."`,
type: Type.API_TYPESCRIPT_COMPILATION,
level: Level.ERROR,
category: ErrorCategory.USER,
},
"10128": {
text: (context): string =>
`It looks like you were trying to add the gatsby-node file? Please rename "${
context.nearMatch
}" to "${context.configName}.${context.isTSX ? `ts` : `js`}"`,
type: Type.API_CONFIG_LOADING,
level: Level.ERROR,
category: ErrorCategory.USER,
},
"10226": {
text: (context): string =>
[
`Couldn't find the "${context.themeName}" plugin declared in "${context.configFilePath}".`,
context.pathToLocalTheme &&
`Tried looking for a local plugin in ${context.pathToLocalTheme}.`,
`Tried looking for an installed package in the following paths:\n${context.nodeResolutionPaths
.map(potentialLocationPath => ` - ${potentialLocationPath}`)
.join(`\n`)}`,
]
.filter(Boolean)
.join(`\n\n`),
type: Type.API_CONFIG_LOADING,
level: Level.ERROR,
category: ErrorCategory.USER,
},
// Plugin errors
"11321": {
text: (context): string =>
`"${context.pluginName}" threw an error while running the ${
context.api
} lifecycle:\n\n${
context.sourceMessage ?? context.message
}${optionalGraphQLInfo(context)}`,
type: Type.API_NODE_EXECUTION,
level: Level.ERROR,
category: ErrorCategory.UNKNOWN,
},
"11322": {
text: (context): string =>
`${
context.pluginName
} created a page and didn't pass the path to the component.\n\nThe page object passed to createPage:\n${JSON.stringify(
context.input,
null,
4
)}`,
level: Level.ERROR,
type: Type.API_NODE_VALIDATION,
category: ErrorCategory.USER,
docsUrl: `https://www.gatsbyjs.com/docs/reference/config-files/actions#createPage`,
},
"11323": {
text: (context): string =>
`${
context.pluginName
} must set the page path when creating a page.\n\nThe page object passed to createPage:\n${JSON.stringify(
context.pageObject,
null,
4
)}`,
level: Level.ERROR,
category: ErrorCategory.USER,
type: Type.API_NODE_VALIDATION,
docsUrl: `https://www.gatsbyjs.com/docs/reference/config-files/actions#createPage`,
},
"11324": {
text: (context): string =>
`Error while creating your page:\n\n${context.message}`,
level: Level.ERROR,
category: ErrorCategory.USER,
type: Type.API_NODE_VALIDATION,
docsUrl: `https://www.gatsbyjs.com/docs/reference/config-files/actions#createPage`,
},
"11325": {
text: (context): string =>
`${
context.pluginName
} created a page with a component that doesn't exist.\n\nThe path to the missing component is "${
context.componentPath
}"\n\nThe page object passed to createPage:\n${JSON.stringify(
context.input,
null,
4
)}`,
level: Level.ERROR,
category: ErrorCategory.USER,
type: Type.API_NODE_VALIDATION,
docsUrl: `https://www.gatsbyjs.com/docs/reference/config-files/actions#createPage`,
},
"11326": {
text: (context): string =>
`${
context.pluginName
} must set the absolute path to the page component when creating a page.\n\nThe (relative) path you used for the component is "${
context.componentPath
}"\n\nYou can convert a relative path to an absolute path by requiring the path module and calling path.resolve() e.g.\n\nconst path = require("path")\npath.resolve("${
context.componentPath
}")\n\nThe page object passed to createPage:\n${JSON.stringify(
context.input,
null,
4
)}`,
level: Level.ERROR,
category: ErrorCategory.USER,
type: Type.API_NODE_VALIDATION,
docsUrl: `https://www.gatsbyjs.com/docs/reference/config-files/actions#createPage`,
},
"11327": {
text: (context): string =>
`An empty file "${context.componentPath}" was found during page creation. Please remove it or make it a valid component.`,
level: Level.ERROR,
category: ErrorCategory.USER,
type: Type.API_NODE_VALIDATION,
docsUrl: `https://www.gatsbyjs.com/docs/reference/config-files/actions#createPage`,
},
"11328": {
text: (context): string =>
`${context.pluginName} created a page without a valid default export.\n\nThe path to the page is "${context.componentPath}". If your page is a named export, please use "export default" instead.`,
level: Level.ERROR,
category: ErrorCategory.USER,
type: Type.API_NODE_VALIDATION,
docsUrl: `https://www.gatsbyjs.com/docs/reference/config-files/actions#createPage`,
},
// invalid or deprecated APIs
"11329": {
text: (context): string =>
[
stripIndent(`
Your plugins must export known APIs from their gatsby-${context.exportType}.
See https://www.gatsbyjs.com/docs/reference/config-files/gatsby-${context.exportType}/ for the list of Gatsby ${context.exportType} APIs.
`),
]
.concat([``].concat(context.errors))
.concat(
context.fixes.length > 0
? [
``,
`Some of the following may help fix the error(s):`,
``,
...context.fixes.map(fix => `- ${fix}`),
]
: []
)
.join(`\n`),
level: Level.ERROR,
category: ErrorCategory.USER,
type: Type.API_NODE_VALIDATION,
},
// "X" is not defined in Gatsby's node APIs
"11330": {
text: (context): string =>
`"${context.pluginName}" threw an error while running the ${
context.api
} lifecycle:\n\n${context.sourceMessage ?? context.message}\n\n${
context.codeFrame
}\n\nMake sure that you don't have a typo somewhere and use valid arguments in ${
context.api
} lifecycle.\nLearn more about ${
context.api
} here: https://www.gatsbyjs.com/docs/reference/config-files/gatsby-node/#${
context.api
}`,
type: Type.API_NODE_VALIDATION,
level: Level.ERROR,
category: ErrorCategory.USER,
},
// Invalid plugin options
"11331": {
text: (context): string =>
[
stripIndent(`
Invalid plugin options for "${context.pluginName}"${
context.configDir ? `, configured by ${context.configDir}` : ``
}:
`),
]
.concat([``])
.concat(
context.validationErrors.map(error => `- ${error.message}`).join(`\n`)
)
.join(`\n`),
type: Type.API_NODE_VALIDATION,
level: Level.ERROR,
category: ErrorCategory.USER,
},
"11332": {
text: (): string =>
`Failed to compile Gatsby Functions. See the error below for more details.\nNote: The src/api folder is a reserved folder for Gatsby Functions and can't be used for any other files.`,
type: Type.FUNCTIONS_COMPILATION,
level: Level.ERROR,
category: ErrorCategory.USER,
docsUrl: `https://www.gatsbyjs.com/docs/reference/functions/`,
},
// slices
"11333": {
text: (context): string =>
`${
context.pluginName
} created a slice and didn't pass the path to the component.\n\nThe slice object passed to createSlice:\n${JSON.stringify(
context.input,
null,
4
)}`,
level: Level.ERROR,
category: ErrorCategory.USER,
type: Type.API_NODE_VALIDATION,
docsUrl: `https://gatsbyjs.com/docs/reference/config-files/actions#createSlice`,
},
"11334": {
text: (context): string =>
`${
context.pluginName
} must set the slice id when creating a slice.\n\nThe slice object passed to createSlice:\n${JSON.stringify(
context.sliceObject,
null,
4
)}`,
level: Level.ERROR,
category: ErrorCategory.USER,
type: Type.API_NODE_VALIDATION,
docsUrl: `https://gatsbyjs.com/docs/reference/config-files/actions#createSlice`,
},
"11335": {
text: (context): string =>
`${
context.pluginName
} must set the absolute path to the slice component when creating a slice.\n\nThe (relative) path you used for the component is "${
context.componentPath
}"\n\nYou can convert a relative path to an absolute path by requiring the path module and calling path.resolve() e.g.\n\nconst path = require("path")\npath.resolve("${
context.componentPath
}")\n\nThe object passed to createSlice:\n${JSON.stringify(
context.input,
null,
4
)}`,
level: Level.ERROR,
category: ErrorCategory.USER,
type: Type.API_NODE_VALIDATION,
docsUrl: `https://gatsbyjs.com/docs/reference/config-files/actions#createSlice`,
},
"11336": {
text: (context): string =>
`${
context.pluginName
} created a slice with a component that doesn't exist.\n\nThe path to the missing component is "${
context.componentPath
}"\n\nThe slice object passed to createSlice:\n${JSON.stringify(
context.input,
null,
4
)}`,
level: Level.ERROR,
category: ErrorCategory.USER,
type: Type.API_NODE_VALIDATION,
docsUrl: `https://gatsbyjs.com/docs/reference/config-files/actions#createSlice`,
},
"11337": {
text: (context): string =>
`An empty file "${context.componentPath}" was found during slice creation. Please remove it or make it a valid component.`,
level: Level.ERROR,
category: ErrorCategory.USER,
type: Type.API_NODE_VALIDATION,
docsUrl: `https://gatsbyjs.com/docs/reference/config-files/actions#createSlice`,
},
"11338": {
text: (context): string =>
`${context.pluginName} created a slice component without a valid default export.\n\nThe path to the component is "${context.componentPath}". If your component is a named export, please use "export default" instead.`,
level: Level.ERROR,
category: ErrorCategory.USER,
type: Type.API_NODE_VALIDATION,
docsUrl: `https://gatsbyjs.com/docs/reference/config-files/actions#createSlice`,
},
"11339": {
text: (context): string =>
[
`Building static HTML failed for slice "${context.sliceName}".`,
`Slice metadata: ${JSON.stringify(context?.sliceData || {}, null, 2)}`,
`Slice props: ${JSON.stringify(context?.sliceProps || {}, null, 2)}`,
]
.filter(Boolean)
.join(`\n\n`),
level: Level.ERROR,
category: ErrorCategory.USER,
type: Type.HTML_COMPILATION,
docsUrl: `https://gatsbyjs.com/docs/reference/config-files/actions#createSlice`,
},
"11340": {
text: (context): string =>
[
`Building static HTML failed for slice "${context.sliceName}".`,
`"${context.undefinedGlobal}" is not available during server-side rendering. Enable "DEV_SSR" to debug this during "gatsby develop".`,
]
.filter(Boolean)
.join(`\n\n`),
level: Level.ERROR,
category: ErrorCategory.USER,
type: Type.HTML_COMPILATION,
docsUrl: `https://gatsbyjs.com/docs/reference/config-files/actions#createSlice`,
},
// node object didn't pass validation
"11467": {
text: (context): string =>
[
`The new node didn't pass validation: ${context.validationErrorMessage}`,
`Failing node:`,
JSON.stringify(context.node, null, 4),
`Note: there might be more nodes that failed validation. Output is limited to one node per type of validation failure to limit terminal spam.`,
context.codeFrame,
]
.filter(Boolean)
.join(`\n\n`),
level: Level.ERROR,
category: ErrorCategory.UNKNOWN,
type: Type.API_NODE_VALIDATION,
docsUrl: `https://www.gatsbyjs.com/docs/reference/config-files/actions#createNode`,
},
// local SSL certificate errors
"11521": {
text: (): string =>
`for custom ssl --https, --cert-file, and --key-file must be used together`,
level: Level.ERROR,
docsUrl: `https://www.gatsbyjs.com/docs/local-https#custom-key-and-certificate-files`,
category: ErrorCategory.USER,
type: Type.CLI_VALIDATION,
},
"11522": {
text: (): string => `Failed to generate dev SSL certificate`,
level: Level.ERROR,
category: ErrorCategory.THIRD_PARTY,
docsUrl: `https://www.gatsbyjs.com/docs/local-https#setup`,
type: Type.CLI_VALIDATION,
},
// cli new command errors
"11610": {
text: (context): string =>
`It looks like you gave wrong argument orders. Try running instead "gatsby new ${context.starter} ${context.rootPath}"`,
level: Level.ERROR,
docsUrl: `https://www.gatsbyjs.com/docs/reference/gatsby-cli#new`,
category: ErrorCategory.USER,
type: Type.CLI_VALIDATION,
},
"11611": {
text: (context): string =>
`It looks like you passed a URL to your project name. Try running instead "gatsby new new-gatsby-project ${context.rootPath}"`,
level: Level.ERROR,
docsUrl: `https://www.gatsbyjs.com/docs/reference/gatsby-cli#new`,
category: ErrorCategory.USER,
type: Type.CLI_VALIDATION,
},
"11612": {
text: (context): string =>
`Could not create a project in "${context.path}" because it's not a valid path`,
level: Level.ERROR,
docsUrl: `https://www.gatsbyjs.com/docs/reference/gatsby-cli#new`,
category: ErrorCategory.USER,
type: Type.CLI_VALIDATION,
},
"11613": {
text: (context): string =>
`Directory ${context.rootPath} is already an npm project`,
level: Level.ERROR,
category: ErrorCategory.USER,
docsUrl: `https://www.gatsbyjs.com/docs/reference/gatsby-cli#new`,
type: Type.CLI_VALIDATION,
},
"11614": {
text: (context): string =>
stripIndent(`
The path "${context.path}" errored during SSR.
Edit its component ${context.filePath}${
context.line ? `:${context.line}:${context.column}` : ``
} to resolve the error.`),
level: Level.WARNING,
category: ErrorCategory.USER,
type: Type.HTML_GENERATION_DEV_SSR,
},
"11615": {
text: (context): string =>
stripIndent(`
There was an error while trying to load dev-404-page:
${context.sourceMessage}`),
level: Level.ERROR,
category: ErrorCategory.SYSTEM,
type: Type.HTML_GENERATION_DEV_SSR,
},
"11616": {
text: (context): string =>
stripIndent(`
There was an error while trying to create the client-only shell for displaying SSR errors:
${context.sourceMessage}`),
level: Level.ERROR,
category: ErrorCategory.SYSTEM,
type: Type.HTML_GENERATION_DEV_SSR,
},
// Watchdog
"11701": {
text: (context): string =>
`Terminating the process (due to GATSBY_WATCHDOG_STUCK_STATUS_TIMEOUT):\n\nGatsby is in "${
context.status
}" state without any updates for ${(
context.stuckStatusWatchdogTimeoutDelay / 1000
).toFixed(
3
)} seconds. Activities preventing Gatsby from transitioning to idle state:\n\n${
context.stuckStatusDiagnosticMessage
}${context.additionalOutput}`,
level: Level.ERROR,
category: ErrorCategory.UNKNOWN,
type: Type.UNKNOWN,
docsUrl: `https://support.gatsbyjs.com/hc/en-us/articles/360056811354`,
},
// Node Manifest warnings
"11801": {
text: ({ inputManifest }): string => `${getSharedNodeManifestWarning(
inputManifest
)} but Gatsby couldn't find a page for this node.
If you want a manifest to be created for this node (for previews or other purposes), ensure that a page was created (and that a ownerNodeId is added to createPage() if you're not using the Filesystem Route API). See https://www.gatsbyjs.com/docs/conceptual/content-sync for more info.\n`,
level: Level.WARNING,
category: ErrorCategory.USER,
type: Type.API_NODE_VALIDATION,
},
"11802": {
text: ({ inputManifest, pagePath }): string =>
`${getSharedNodeManifestWarning(
inputManifest
)} but Gatsby didn't find an ownerNodeId for the page at ${pagePath}\nUsing the first page that was found with the node manifest id set in pageContext.id in createPage().\nThis may result in an inaccurate node manifest (for previews or other purposes). See https://www.gatsbyjs.com/docs/conceptual/content-sync for more info.`,
level: Level.WARNING,
category: ErrorCategory.USER,
type: Type.API_NODE_VALIDATION,
},
"11805": {
text: ({ inputManifest, pagePath }): string =>
`${getSharedNodeManifestWarning(
inputManifest
)} but Gatsby didn't find an ownerNodeId for the page at ${pagePath}\nUsing the first page that was found with the node manifest id set in pageContext.slug in createPage().\nThis may result in an inaccurate node manifest (for previews or other purposes). See https://www.gatsbyjs.com/docs/conceptual/content-sync for more info.`,
level: Level.WARNING,
category: ErrorCategory.USER,
type: Type.API_NODE_VALIDATION,
},
"11803": {
text: ({ inputManifest, pagePath }): string =>
`${getSharedNodeManifestWarning(
inputManifest
)} but Gatsby didn't find an ownerNodeId for the page at ${pagePath}\nUsing the first page where this node is queried.\nThis may result in an inaccurate node manifest (for previews or other purposes). See https://www.gatsbyjs.com/docs/conceptual/content-sync for more info.`,
level: Level.WARNING,
category: ErrorCategory.USER,
type: Type.API_NODE_VALIDATION,
},
"11804": {
text: ({ pluginName, nodeId }): string =>
`Plugin ${pluginName} called unstable_createNodeManifest for a node which doesn't exist with an id of ${nodeId}`,
level: Level.WARNING,
category: ErrorCategory.USER,
type: Type.API_NODE_VALIDATION,
},
// Parcel Compilation Errors
"11901": {
text: (context): string =>
stripIndent(`
Failed to compile Gatsby files ${
context.origin ? `(${context.origin})` : ``
}:
${context.generalMessage}. ${context.specificMessage ?? ``}
${
context.hints
? context.hints.map(
h => `
Hints:
- ${h}\n`
)
: ``
}
${context.filePath ? `File path: ${context.filePath}` : ``}`),
level: Level.ERROR,
type: Type.API_TYPESCRIPT_COMPILATION,
category: ErrorCategory.USER,
},
"11902": {
text: (context): string =>
`We encountered an error while trying to compile your site's ${context.configName}. Check the current limitations (https://gatsby.dev/ts-limitations), fix the error, and try again.`,
level: Level.ERROR,
type: Type.API_TYPESCRIPT_COMPILATION,
category: ErrorCategory.USER,
},
"11903": {
text: (context): string =>
`There was an unhandled error during compilation for ${context.siteRoot}. Please run the command with the --verbose flag again.\n${context.sourceMessage}`,
level: Level.ERROR,
type: Type.API_TYPESCRIPT_COMPILATION,
category: ErrorCategory.USER,
},
"11904": {
text: (context): string =>
`Expected compiled files not found after compilation for ${
context.siteRoot
} after ${context.retries} retries.\nFile expected to be valid: ${
context.compiledFileLocation
}${
context.sourceFileLocation
? `\nCompiled from: ${context.sourceFileLocation}`
: ``
}\n\nPlease run "gatsby clean" and try again. If the issue persists, please open an issue with a reproduction at https://gatsby.dev/new-issue for more help.`,
level: Level.ERROR,
type: Type.API_TYPESCRIPT_COMPILATION,
category: ErrorCategory.SYSTEM,
},
"12100": {
text: (
context
): string => `There was an error while trying to generate TS types from your GraphQL queries:
${context.sourceMessage}`,
level: Level.ERROR,
type: Type.API_TYPESCRIPT_TYPEGEN,
category: ErrorCategory.USER,
docsUrl: `https://gatsby.dev/graphql-typegen`,
},
// Gatsby Adapters
"12200": {
text: (): string =>
`Tried to create adapter routes for webpack assets but failed. If the issue persists, please open an issue with a reproduction at https://gatsby.dev/bug-report for more help.`,
level: Level.ERROR,
type: Type.ADAPTER,
category: ErrorCategory.SYSTEM,
},
// Currently not used, as the error was turned into warning
// Might be used in next major version of gatsby, but we still have to keep it
// because older gatsby versions might try to use this error ID
"12201": {
text: (context): string =>
`Adapter "${
context.adapterName
}" is not compatible with following settings:\n${context.incompatibleFeatures
.map(line => ` - ${line}`)
.join(`\n`)}`,
level: Level.ERROR,
type: Type.ADAPTER,
category: ErrorCategory.THIRD_PARTY,
},
// Partial hydration
"80000": {
text: (context): string =>
stripIndents(`Building partial HTML failed${
context?.path ? ` for path "${context.path}"` : ``
}
This can happen if interactive elements like "useEffect", "useState", "createContext" or event handlers are used in a component without declaring the "use client" directive at the top of the file.
Consider adding "use client" to the top of your file if your component is interactive, otherwise refactor your component so it can be statically rendered with React Server Components (RSC).
`),
level: Level.ERROR,
type: Type.RSC_COMPILATION,
docsUrl: `https://gatsby.dev/partial-hydration-error`,
category: ErrorCategory.USER,
},
"80001": {
text: (): string =>
stripIndents(
`
Failed to restore previous client module manifest.
This can happen if the manifest is corrupted or is not compatible with the current version of Gatsby.
Please run "gatsby clean" and try again. If the issue persists, please open an issue with a reproduction at https://gatsby.dev/new-issue for more help.
`
),
level: Level.ERROR,
type: Type.RSC_COMPILATION,
docsUrl: `https://gatsby.dev/partial-hydration-error`,
category: ErrorCategory.THIRD_PARTY,
},
}
export type ErrorId = string | keyof typeof errors
export const errorMap: Record<ErrorId, IErrorMapEntry> = errors
export const defaultError = errorMap[``]
export interface IErrorMapEntry {
text: (context) => string
// Public facing API (e.g. used by setErrorMap) doesn't rely on enum but gives an union with string interpolation
level: `${Level}`
type: `${Type}` | ((context) => `${Type}`)
category: `${ErrorCategory}`
docsUrl?: string
}
// Make level and type optional for plugins
export interface IErrorMapEntryPublicApi
extends Omit<IErrorMapEntry, "level" | "type"> {