Skip to content

[BUG] CLI crashes with TypeError when AsyncAPI document file is empty #1993

@sahillllllllll-bit

Description

@sahillllllllll-bit

Describe the bug.

When running the AsyncAPI CLI with an empty AsyncAPI file, the CLI crashes with a raw JavaScript TypeError instead of showing a user-friendly validation error.

Expected behavior

The CLI should detect that the AsyncAPI file is empty and return a clear error message, such as:

The provided AsyncAPI file is empty or invalid.

Screenshots

Image

How to Reproduce

  1. Create an empty AsyncAPI file:
touch empty.yaml
  1. Create a minimal valid generator template:
mkdir -p test-template/template
cat > test-template/package.json <<EOF
{
  "name": "test-template",
  "version": "1.0.0",
  "generator": ">=2.0.0"
}
EOF
echo "test" > test-template/template/test.txt
  1. Run the AsyncAPI CLI:
asyncapi generate fromTemplate empty.yaml ./test-template -o out

🖥️ Device Information [optional]

  • Operating System (OS): Windows(WSL)
  • Browser:
  • Browser Version:

👀 Have you checked for similar open issues?

  • I checked and didn't find similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to work on this issue ?

yes

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    To Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions