fix: detect and reject multi-document YAML files with clear error (fixes #1997)#2115
fix: detect and reject multi-document YAML files with clear error (fixes #1997)#2115armorbreak001 wants to merge 2 commits intoasyncapi:masterfrom
Conversation
asyncapi#1997) When a YAML file contains multiple documents separated by ---, the parser produces confusing low-level errors. This fix detects multi-document YAML early in Specification.fromFile() and throws a clear, user-facing error message. Also extends ErrorLoadingSpec to support optional customMessage parameter for more specific error context. Fixes asyncapi#1997
|
Extended multi-document YAML detection to fromURL() in addition to fromFile(). URLs can also return multi-document YAML content.
|
|
Hi maintainers! This PR has been waiting for review for ~53 hours now and has passed all checks (SonarCloud ✅, CI ✅, mergeable ✅). The issue it addresses is a bounty task. Would love to get a review — happy to address any feedback quickly. Thanks! |
|
👋 Hi maintainers! PR has been waiting 48h+. Happy to address any feedback. Please let me know if anything needs adjusting! |
|
👋 Hi maintainers — third follow-up on this PR. It's been waiting ~72h now with all checks green (SonarCloud ✅ CI ✅ MERGEABLE ✅). This fixes a real user pain point (confusing multi-doc YAML error). Happy to refine further if you'd like changes. Just let me know! |
|
👋 Hi maintainers — fourth follow-up here. PR has been waiting ~90 hours now with all checks green (SonarCloud ✅ CI ✅ MERGEABLE ✅). Happy to address any feedback or make adjustments. Just let me know! |
|
👋 Hi maintainers — 5th follow-up. PR waiting ~96h, all checks green. Bounty window closing soon. Happy to address any feedback! |
|
👋 Hi maintainers — 6th follow-up. PR waiting ~108h now, all checks green (SonarCloud ✅ CI ✅ MERGEABLE ✅). Bounty window closing soon (Beijing time 2026-04-20). Happy to address any feedback! Thanks |



Description
Fixes #1997
Problem
When an AsyncAPI YAML file contains multiple documents (separated by
---), the CLI fails with a confusing low-level parser error instead of clearly detecting the condition.Multi-document YAML is valid YAML and commonly appears in real workflows (Kubernetes configs, merged files, copy-paste artifacts). Users reasonably expect a clear rejection message.
Solution
Detect multiple YAML document separators (
---) inSpecification.fromFile()before parsing. If more than one separator is found, throw a clear error:Changes
fromFile()ErrorLoadingSpecwith optionalcustomMessageparam for specific error contextTesting
---separators at start of line