Skip to content

fix: detect and reject multi-document YAML files with clear error (fixes #1997)#2115

Open
armorbreak001 wants to merge 2 commits intoasyncapi:masterfrom
armorbreak001:bounty/1997-multidoc-yaml
Open

fix: detect and reject multi-document YAML files with clear error (fixes #1997)#2115
armorbreak001 wants to merge 2 commits intoasyncapi:masterfrom
armorbreak001:bounty/1997-multidoc-yaml

Conversation

@armorbreak001
Copy link
Copy Markdown

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 (---) in Specification.fromFile() before parsing. If more than one separator is found, throw a clear error:

Error: File contains multiple YAML documents (2 separators found).
AsyncAPI only supports single-document YAML files.
Please split the file or remove extra --- separators.

Changes

  • src/domains/models/SpecificationFile.ts: Multi-doc detection in fromFile()
  • src/errors/specification-file.ts: Extended ErrorLoadingSpec with optional customMessage param for specific error context

Testing

  • Only triggers on files with 2+ --- separators at start of line
  • Preserves normal single-document file loading behavior
  • Error message is actionable — tells user exactly what to do

 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
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 13, 2026

⚠️ No Changeset found

Latest commit: 958c107

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-project-automation github-project-automation Bot moved this to To Triage in CLI - Kanban Apr 13, 2026
Extended multi-document YAML detection to fromURL() in addition
to fromFile(). URLs can also return multi-document YAML content.
@sonarqubecloud
Copy link
Copy Markdown

@a638011
Copy link
Copy Markdown

a638011 commented Apr 15, 2026

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!

@a638011
Copy link
Copy Markdown

a638011 commented Apr 15, 2026

👋 Hi maintainers! PR has been waiting 48h+. Happy to address any feedback. Please let me know if anything needs adjusting!

@a638011
Copy link
Copy Markdown

a638011 commented Apr 16, 2026

👋 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!

@a638011
Copy link
Copy Markdown

a638011 commented Apr 17, 2026

👋 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!

@a638011
Copy link
Copy Markdown

a638011 commented Apr 18, 2026

👋 Hi maintainers — 5th follow-up. PR waiting ~96h, all checks green. Bounty window closing soon. Happy to address any feedback!

@a638011
Copy link
Copy Markdown

a638011 commented Apr 18, 2026

👋 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: To Triage

Development

Successfully merging this pull request may close these issues.

[BUG] CLI fails with misleading error when AsyncAPI YAML contains multiple documents

2 participants