Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: null check when checking schemaFormat in array items #786

Merged
merged 1 commit into from
Jun 14, 2023

Conversation

chrispatmore
Copy link
Contributor

Description

due to a quirk of how nimma generates the evaluation logic for checking fields in objects inside an array whilst filtering it is possible to get an npe. Adding specific checks against this.

Related issue(s)
Fixes #784

due to a quirk of how nimma generates the evaluation logic
for checking fields in objects inside an array whilst filtering
it is possible to get an npe. Adding specific checks against
this.

Contributes to: asyncapi#784

Signed-off-by: Chris Patmore <[email protected]>
@@ -31,6 +31,7 @@ export function testRule(ruleName: RuleNames, tests: Scenario,): void {
const doc = JSON.stringify(testCase.document);

const errors = await parser.validate(doc);
expect(errors.filter(({ code }) => code === 'uncaught-error')).toHaveLength(0);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

test wasn't seeing the uncaught errors which threw me for a long time

@@ -123,17 +123,17 @@ export const v2CoreRuleset = {
given: [
// messages
'$.channels.*.[publish,subscribe].[?(@property === \'message\' && @.schemaFormat === void 0)]',
'$.channels.*.[publish,subscribe].message.oneOf[?(@.schemaFormat === void 0)]',
'$.channels.*.[publish,subscribe].message.oneOf[?(!@null && @.schemaFormat === void 0)]',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

just null check anywhere we are checking the value of a property inside an object

@sonarcloud
Copy link

sonarcloud bot commented Jun 13, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Copy link
Member

@jonaslagoni jonaslagoni left a comment

Choose a reason for hiding this comment

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

👍

@jonaslagoni
Copy link
Member

/rtm

@asyncapi-bot asyncapi-bot merged commit 74cfce1 into asyncapi:master Jun 14, 2023
@asyncapi-bot
Copy link
Contributor

🎉 This PR is included in version 2.0.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

@chrispatmore chrispatmore deleted the 784-null-schema-format branch June 15, 2023 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants