-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
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
2.0.0-alpha.73 can't handle tags which could be parsed as numbers #4642
Comments
Make sense, I'll add the Joi {convert: true} option, that should fix it. Also worth logging the doc frontmatter in the error message 😅 was it easy to find the problematic blog post? |
So I saw the failure when the GitHub Action ran - I then ran This told me where the error was thrown, so I added a bunch of If you point me in the direction of the relevant bit of code I'd be happy to submit a fix PR myself if that helps? |
Is it here?
So it could be: Joi.attempt(frontMatter, BlogFrontMatterSchema, undefined, { convert: true }); https://joi.dev/api/?v=17.4.0#attemptvalue-schema-message-options Or alternatively, const BlogTagSchema = Joi.alternatives().try(
Joi.string().required(),
Joi.object<Tag>({
label: Joi.string().required(),
permalink: Joi.string().required(),
}),
); could become const BlogTagSchema = Joi.alternatives().try(
Joi.string().required(),
Joi.number().required(),
Joi.object<Tag>({
label: Joi.string().required(),
permalink: Joi.string().required(),
}),
); |
Yes that's here, I'd prefer to use "convert" as in the end we want the tag to be a string. And we should also convert tag labels from numbers to string when they are using the object version. Can you also add a try/catch around the try {
return attempt(frontMatter);
} catch (e) {
console.error(chalk.red("bad frontmatter: " + JSON.stringify(frontmatter)));
throw e;
} This way users will be able to identify the problematic md file more easily Also can you add a test for this specific usecase of title (ensuring we don't remove the convert: true option) Also related to #4591 |
See questions on the related WIP PR. |
🐛 Bug Report
As of 2.0.0-alpha.73, docusaurus will choke on tags that can be parsed as numbers.
Consider the following:
The
203
tag above is bad news and will lead to an error like this:See: https://github.com/johnnyreilly/blog.johnnyreilly.com/pull/35/checks?check_run_id=2377642622
You can workaround it by changing
203
to be'203'
, but ideally this wouldn't be necessary.Have you read the [Contributing Guidelines on issues]
Yes
To Reproduce
Follow the example above and then
yarn build
Expected behavior
Compilation works.
Actual Behavior
An error of the nature:
Your Environment
Locally in Linux and in GitHub Actions
Reproducible Demo
See linked PR: johnnyreilly/blog.johnnyreilly.com#35
I've opted to go with the workaround for now; but I thought I should share the experience. Certainly the error message isn't the most helpful in the world.
The text was updated successfully, but these errors were encountered: