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

Zalando rule 169 introduces an issue for null properties #59

Open
johannesmarx opened this issue Jun 6, 2024 · 1 comment
Open

Zalando rule 169 introduces an issue for null properties #59

johannesmarx opened this issue Jun 6, 2024 · 1 comment

Comments

@johannesmarx
Copy link
Contributor

johannesmarx commented Jun 6, 2024

Somehow it seems that the newly introduced Zalando rule 169 causes an issue in cases with null properties.

I stumbled over the issue in a case where a response example references an Example that contains a null property.

To better illustrate the issue, I created a draft PR that showcases it: #60

       resonses:
       ...
           application/json:
              schema:
                $ref: '#/components/schemas/Example'
              examples:
                default:
                  $ref: '#/components/examples/ExampleResponse'

...

components:
 ...
  examples:
    ExampleResponse:
      summary: example response summary
      value:
        name: null # this null value causes the exception

This is the resulting stack trace:

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

      at Object.$.paths..[?(@.type === 'string' && (@.format === 'date-time' || @.format === 'date' || @.format === 'time' || @.format === 'duration' || @.format === 'period'))] (eval at query (node_modules/nimma/dist/legacy/cjs/core/index.js:66:71), <anonymous>:117:31)
      at eval (eval at query (node_modules/nimma/dist/legacy/cjs/core/index.js:66:71), <anonymous>:201:176)
      at _traverseBody (node_modules/nimma/dist/legacy/cjs/runtime/traverse.js:13:5)
      at _traverse (node_modules/nimma/dist/legacy/cjs/runtime/traverse.js:41:7)
      at _traverseBody (node_modules/nimma/dist/legacy/cjs/runtime/traverse.js:17:5)

Side note: I'm not sure if the operator === is "standard" for JSONPath filters but it seems not to cause the issue. Never the less == seem to be more common.

@johannesmarx
Copy link
Contributor Author

@dweber019 did you had a chance to look into the issue?

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

No branches or pull requests

1 participant