Skip to content

fix: handle null message objects in spectral JSONPath filters - #1232

Open
Luvi-1 wants to merge 1 commit into
asyncapi:masterfrom
Luvi-1:fix/null-message-schemaformat
Open

fix: handle null message objects in spectral JSONPath filters#1232
Luvi-1 wants to merge 1 commit into
asyncapi:masterfrom
Luvi-1:fix/null-message-schemaformat

Conversation

@Luvi-1

@Luvi-1 Luvi-1 commented Aug 24, 2026

Copy link
Copy Markdown

Description

When a payload property is literally named and has a value (e.g. in a message example), the spectral JSONPath filter expressions that check crash with:

TypeError: Cannot read properties of null (reading 'schemaFormat')

This happens because the filter expression walks into the payload's properties and encounters the property named with value , then tries to read on it.

Several paths already had guards; this PR adds them to all expressions that were missing them.

Before / after

Before:

Error thrown during AsyncAPI document validation. Name: TypeError, message: Cannot read properties of null (reading 'schemaFormat')

After:

  • No crash, document parses cleanly
  • Standard lint suggestions remain, no TypeError

Fixes #863

When a payload property is named message and has a null value in an example, JSONPath filter expressions that check @.schemaFormat crash with a TypeError. Added !@null guards matching the pattern already used by other paths in the same ruleset.

Fixes asyncapi#863
@changeset-bot

changeset-bot Bot commented Aug 24, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 68fb88d

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-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 AsyncAPI. Thanks a lot for creating your first pull request. Please check out our contributors guide useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

@sonarqubecloud

Copy link
Copy Markdown

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.

Payload property named message breaks with null value

1 participant