Summary
When a file has invalid YAML in its frontmatter block (e.g. markdown content between --- delimiters), gray-matter throws a YAMLException. This exception propagates unhandled and crashes the entire validate run rather than being caught and reported as a validation error on that specific file.
Expected behaviour
The file is reported as a validation error (e.g. YAML parse error: <reason>) in the normal validation output, and validation continues for the rest of the space.
Actual behaviour
The process throws and exits with a stack trace, producing no validation summary at all.
Reproduction
A file with an opening --- followed by markdown content that is syntactically invalid YAML (e.g. bold syntax **text**) will trigger this. Example frontmatter:
---
## Summary
**Key contacts**: Alice (Constituency A), Bob (Constituency B).
gray-matter interprets everything up to the closing --- as YAML. The ** syntax is not valid YAML and triggers a YAMLException.
Stack trace (excerpt)
YAMLException: end of the stream or a document separator is expected at line 6, column 17
Notes
The fix is to wrap the per-file gray-matter parse call in a try/catch and surface the error as a structured validation failure on that file path, consistent with how schema validation errors are reported.
Summary
When a file has invalid YAML in its frontmatter block (e.g. markdown content between
---delimiters), gray-matter throws aYAMLException. This exception propagates unhandled and crashes the entirevalidaterun rather than being caught and reported as a validation error on that specific file.Expected behaviour
The file is reported as a validation error (e.g.
YAML parse error: <reason>) in the normal validation output, and validation continues for the rest of the space.Actual behaviour
The process throws and exits with a stack trace, producing no validation summary at all.
Reproduction
A file with an opening
---followed by markdown content that is syntactically invalid YAML (e.g. bold syntax**text**) will trigger this. Example frontmatter:gray-matter interprets everything up to the closing
---as YAML. The**syntax is not valid YAML and triggers aYAMLException.Stack trace (excerpt)
Notes
The fix is to wrap the per-file gray-matter parse call in a try/catch and surface the error as a structured validation failure on that file path, consistent with how schema validation errors are reported.