Skip to content

fix: handle null schemaType in assignType for composed schemas - #1835

Open
itsmib wants to merge 1 commit into
springwolf:mainfrom
itsmib:fix/null-schema-type-npe
Open

fix: handle null schemaType in assignType for composed schemas#1835
itsmib wants to merge 1 commit into
springwolf:mainfrom
itsmib:fix/null-schema-type-npe

Conversation

@itsmib

@itsmib itsmib commented Aug 23, 2026

Copy link
Copy Markdown

Problem

SwaggerSchemaMapper.assignType calls Set.of(schemaType) when the
swagger Schema has a null type. Set.of rejects null, causing an NPE
for any property whose schema is a composed schema (allOf/oneOf/anyOf)
which legitimately carries no type.

This silently drops channels/operations from the published AsyncAPI
document, the only signal being a WARN log with null as the message.

Changes

  • Added null check in assignType before calling Set.of(schemaType)
  • Improved warning log in DefaultChannelsService and
    DefaultOperationsService to show exception class name when
    getMessage() returns null

Test

Added mapNullTypeForComposedSchema test in SwaggerSchemaMapperTest
to verify no NPE is thrown for schemas with null type.

Fixes #1834

…posed schemas

Set.of() rejects null values, causing an NPE when a composed schema
(allOf/oneOf/anyOf) has no explicit type. Added null check before
calling Set.of(schemaType).

Also improved warning log messages in DefaultChannelsService and
DefaultOperationsService to show exception class name when message
is null, making startup errors easier to diagnose.

Fixes springwolf#1834
@netlify

netlify Bot commented Aug 23, 2026

Copy link
Copy Markdown

Deploy Preview for springwolf-ui canceled.

Name Link
🔨 Latest commit d1fdef6
🔍 Latest deploy log https://app.netlify.com/projects/springwolf-ui/deploys/6a8a7793145ad8000846a94b

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welcome to Springwolf. Thanks a lot for creating your first pull request. Please check out our contributors guide and feel free to join us on discord.

@timonback

Copy link
Copy Markdown
Member

Hi @itsmib,
thank you for the fix and the included test to ensure that it is covered long term.

I am not sure about the benefit of logging the name of the exception, in case the message of the exception is null. The exception including stacktrace is logged anyway and part of the log.
The original issue is the missing knowledge, which method/payload triggered the issue. Something that is partly covered by the DEBUG level logging, but can be improved upon.

For this PR, can you revert the logging changes?
The fix and test look great!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NPE in SwaggerSchemaMapper.assignType when a property schema has no type (composed schema)

2 participants