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

Studio AsyncAPI: Cannot read properties of null - Issue with property named "message" #416

Closed
NickManit opened this issue Mar 22, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@NickManit
Copy link

Describe the bug

I am currently getting the following error from studio.asyncapi.com when I use asyncapi version >=2.4.0:

Error thrown during AsyncAPI document validation. Name: TypeError, message: Cannot read properties of null (reading 'oneOf'), stack: TypeError: Cannot read properties of null (reading 'oneOf') at $.channels.*.[publish,subscribe][?(@Property === "message" && @.oneOf == void 0)] (eval at value (https://studio.asyncapi.com/static/js/main.13c62293.js:2:4582376), :561:71) at eval (eval at value (https://studio.asyncapi.com/static/js/main.13c62293.js:2:4582376), :634:98) at o (https://studio.asyncapi.com/static/js/main.13c62293.js:2:4607027) at a (https://studio.asyncapi.com/static/js/main.13c62293.js:2:4607290) at o (https://studio.asyncapi.com/static/js/main.13c62293.js:2:4607056) at a (https://studio.asyncapi.com/static/js/main.13c62293.js:2:4607290) at o (https://studio.asyncapi.com/static/js/main.13c62293.js:2:4607056) at a (https://studio.asyncapi.com/static/js/main.13c62293.js:2:4607227) at o (https://studio.asyncapi.com/static/js/main.13c62293.js:2:4607056) at a (https://studio.asyncapi.com/static/js/main.13c62293.js:2:4607290)

How to Reproduce

Simply change the version of asyncapi from 2.3.0 to 2.4.0 or above, and the error I mentioned will be thrown:

asyncapi: 2.3.0
info:
  title: Customer Message
  version: 1.0.0
channels:
  /test/url/customer-message:
    publish:
      operationId: customer-message
      message:
        name: customer-message
        contentType: application/json
        payload:
          $ref: '#/components/schemas/CustomerMessage'
        examples:
          - payload:
              customerId: "123"
              message: null
          - payload:
              customerId: "123"
              message: string
components:
  schemas:
    CustomerMessage:
      type: object
      properties:
        customerId:
          nullable: false
          type: string
        message:
          nullable: true
          type: string

Expected behavior

As far as I understood, this error is related with two things:

  1. The name of the "message" property. If I change the name to "msg", it works fine.
  2. The example where message: null. If I set a different value, then it also works fine.

However, I do not think this is the normal behaviour. I guess the expected behaviour is to accept this structure and not throw an error. Could someone please clarify?

@NickManit NickManit added the bug Something isn't working label Mar 22, 2023
@github-actions
Copy link

Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Please check out our contributors guide and the instructions about a basic recommended setup 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.

@derberg
Copy link
Member

derberg commented Apr 3, 2023

@NickManit hey there, sorry for delay in response.

The core of all the problems you see is nullable in your example. There is no such thing in AsyncAPI Schema that you are using out there.

AsyncAPI Schema that is superset of JSON Schema doesn't define nullable. I assume you took it from OpenAPI Schema.

Are you trying to reuse your OpenAPI Schemas in AsyncAPI documents? which is completely valid case that we should further investigate.

If you do not need OpenAPI Schema, then I suggest replacing nullable with type: [ "string", "null" ]

@github-actions
Copy link

github-actions bot commented Aug 2, 2023

This issue has been automatically marked as stale because it has not had recent activity 😴

It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.

There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.

Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.

Thank you for your patience ❤️

@github-actions github-actions bot added the stale label Aug 2, 2023
@derberg
Copy link
Member

derberg commented Sep 14, 2023

no response, I guess my previous comment solved the bug

@derberg derberg closed this as completed Sep 14, 2023
@derberg derberg removed the stale label Sep 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants