-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gatsby-transformer-json crashes when .json file in directory starting with a number #20596
Comments
Some context here. @freiksenet @vladar Where do you think this should be addressed - should this be plugin responsibility to create node types that are valid, or would it be ok to ensure proper types in core, so plugins don't have to worry about this? |
Probably the best thing here would be to A) Throw a better exception so that it's clear what's going on in core.. and then B) put it on the plugin guys to deal with this problem.. it would be solved if the plugin did prefixing rather than suffixing.. ie. Name it Json_20M rather than 20MJson. However that's a breaking change for existing sites. At a minimum a better error message from core would make life a lot easier. |
Can we import some typename validation utils, or would we have to re-implement them?
The thing is - lot of those are autogenerated by plugins, where users might not have control over it, so only course of action would be to report that issue to plugin maintainers. But plugins also often reuse some type names from source of their data and to "fix" the issue they would need to implement some type name normalisation anyway - so that means we just shift where the normalization happen from core to plugins (which also mean normalization will need to be re-implemented in lot of plugins). |
Validation is simple - it is pretty much defined in spec as regex We use this to generate query names from file paths (which would work for type names too): gatsby/packages/gatsby/src/query/file-parser.js Lines 28 to 40 in acf2c35
Maybe we can extract common util from it and update a bit (i.e. obviously it won't work for this specific issue since it won't prefix numbers). Then we can use it in |
Hiya! This issue has gone quiet. Spooky quiet. 👻 We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here. Thanks for being a part of the Gatsby community! 💪💜 |
@wuntusk Looks like we'd missed an option in See plugin docs for details. |
@vladar Agreed that does allow someone to deal with invalid folder names. To verify I dropped this function in which allowed everything to build fine.
That being said it'd still be great to give a better error message than UNHANDLED REJECTION Syntax Error: Unexpected Int "20" I don't think that error message is going to lead most people to quickly figure out what's wrong. It probably also wouldn't hurt to drop some info on the gatsby-transformer-json plugin doc about this situation. But that probably belongs in another issue? |
Agreed! Tho we wouldn't be able to provide much context anyway, but we could print that data (nodes) created by plugin X (we know which plugin owns particular node types) have invalid As for documention - we probably could have Troubleshooting section in |
I am getting into the same issue:
file name:
|
Closing this as stale since in the meantime Gatsby v3 and updated related packages were released. Please try with the latest versions and if you still see this problem open a new bug report (it must include a minimal reproduction). |
Description
When running gatsby develop if you have the gatsby-transformer-json installed and anywhere in you file system you have a .json file directly inside a directory that starts with a number gatsby will crash with
Steps to reproduce
add
"gatsby-transformer-json"
{
resolve:
gatsby-source-filesystem
,options: {
path:
${__dirname}/src/assets
,},
},
to your gatsby-config.js
create a directory called 20m in your src/assets directory
create a file called test.json in your src/assets/20m directory with the contents
Repro Project
Expected result
Json Data should be added to the system
Actual result
gatsby develop crashes:
Environment
System:
OS: Windows 10 10.0.17763
CPU: (16) x64 AMD Ryzen 7 1800X Eight-Core Processor
Binaries:
Node: 12.14.0 - C:\Program Files\nodejs\node.EXE
npm: 6.13.4 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: 44.17763.831.0
The text was updated successfully, but these errors were encountered: