-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomers
Description
Describe the bug.
The AsyncApi DSL allows creating an instance without initializing mandatory fields such as info and channels.
This leads to a runtime crash during JSON serialization, instead of failing fast with a clear validation error.
The issue occurs because these mandatory fields are defined using lateinit, which bypasses compile-time checks and throws an exception only when accessed at runtime.
Expected behavior
- The
AsyncApiDSL should fail fast when mandatory fields such asinfoandchannelsare not defined. - A clear, descriptive validation error should be thrown, indicating which required fields are missing.
- The error should occur before or during DSL validation, not later during JSON serialization.
- Runtime crashes caused by
lateinitaccess should be avoided. - Users should not be able to generate or serialize an invalid AsyncAPI document.
Screenshots
Failing test output when running mvn -pl kotlin-asyncapi-core test:
This shows a runtime failure caused by accessing an uninitialized lateinit property
(AsyncApi["info"]) during Jackson serialisation.
How to Reproduce
- Clone the repository:
git clone https://github.com/asyncapi/kotlin-asyncapi.git cd kotlin-asyncapi - Add code that creates an AsyncApi instance without setting required fields and serialise it:
val asyncApi = AsyncApi() ObjectMapper().writeValueAsString(asyncApi)
- Run the core module tests:
mvn -pl kotlin-asyncapi-core test - The build fails with:
lateinit property info has not been initialized
🖥️ Device Information [optional]
- Operating System (OS): macOS
- Browser: Google Chrome
- Browser Version: 144.0.0.0
👀 Have you checked for similar open issues?
- I checked and didn't find similar issue
🏢 Have you read the Contributing Guidelines?
- I have read the Contributing Guidelines
Are you willing to work on this issue ?
Yes I am willing to submit a PR!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomers