fix: guard nullable 'message' fields in v2 ruleset (issue #863) - #1229
fix: guard nullable 'message' fields in v2 ruleset (issue #863)#1229tzh476 wants to merge 4 commits into
Conversation
…syncapi#863) Change-Id: Ia9549f33f1c06d3a56c4af9f6d01c6596e645a98
🦋 Changeset detectedLatest commit: 7cead1a The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Change-Id: I9fa2cccd89ac357e05c1be34432b042d55edb15c
|
Hi maintainers - friendly ping: this PR (fixes #863, guard nullable message fields) is ready and MERGEABLE, changeset added, CI/SonarCloud passing; happy to adjust on review. Thank you. |
…ge guards This PR changed eight JSONPath expressions but shipped no test, so nothing prevented the guards from being dropped again. The test drives the public `parser.validate()` path with the exact document shape from issue asyncapi#863 -- a schema property literally named `message` whose example value is `null`. Removing the `!@null` guards makes it fail with the error from the issue: TypeError: Cannot read properties of null (reading 'schemaFormat') One detail worth recording, because it decides what the test must assert: `validate()` **resolves** even on the unfixed code and reports the crash as a diagnostic rather than rejecting. A "does it throw" assertion therefore passes both before and after the fix and would have guarded nothing. The two assertions that actually catch the regression are the diagnostic check and the `parse()` check. Measured on this branch: with guards 3 passed guards removed 2 failed, 1 passed (the throw-based one is the passer) Change-Id: I7b412b6d5b11132d332913a49ca0263f7c578bef Disclosure: prepared by a human working with an LLM assistant.
|
|
Pushed The new spec drives the public Control experiment, guards removed: Guards in place: 3 passed. One detail worth recording, because it decides what the test has to assert: Current state: For context on the fix itself: Disclosure: human + LLM collaboration; the numbers above are from runs on this branch. |



Fixes #863.
When a payload object has a nullable property literally named
message, v2-ruleset selectors navigating@property === "message"read.schemaFormat/.oneOfonnulland crash validation.Guard added:
!@null &&before those reads inruleset/v2/ruleset.ts(message-examples, payload default/examples, operation-message) andruleset/v2/functions/messageExamples-spectral-rule-v2.ts.Verified: the issue example now validates with no error diagnostic; ruleset/validate suite passes (43 suites / 244 tests).