asyncapi-react icon indicating copy to clipboard operation
asyncapi-react copied to clipboard

AsyncAPI renderer crashing

Open char0n opened this issue 10 months ago • 6 comments

Hi everybody,

I've noticed that on following AsyncAPI 2.6.0 document, the renderer catastrophically crashes. There is no way of recovery. This also manifest in https://studio.asyncapi.com/ where the document is stored in local storage under document key and subsequent refreshes results in never ending splash screen.

Affected version: @asyncapi/react-component =1.0.0-next.48

Document:

asyncapi: '2.6.0'
info:
  title: AsyncAPI
  version: '1.0.0'
channels:
  'foo':
    description: Bar.
    publish:
      message:
        oneOf:
          - $ref: '#/components/messages/Foo'
       
          
components:
  messages:
    Foo:
      name: Foo
      payload:
        $ref: "#/components/schemas/Bar"
      examples:
        - name: standard
          payload:
            after: 
              oneOf:
              - $ref: '#/components/messages/Foo'
              
  schemas:
    Bar:
      type: object
      properties:
        eventType:
          type: string
          desciption: Foo

Never ending splash screen:

image

char0n avatar Aug 07 '23 11:08 char0n

@char0n Circular references in message examples aren't supported, only in schemas.

magicmatatjahu avatar Aug 07 '23 12:08 magicmatatjahu

@magicmatatjahu yep I do understand that, thus I would expect the renderer to treat the $ref field as normal field name without any significance. Even if it would be supported still I wouldn't expect the render to crash and properly recover.

char0n avatar Aug 07 '23 12:08 char0n

Just describing my understand of Message Example Object.payload field in more detail here. The specification for AsyncAPI 2.6 says:

image

any means that arbitrary data can be provided there and no special processing happens.

char0n avatar Aug 07 '23 12:08 char0n

The parser tries to resolve the references and we do not exclude the refs in the payload's examples, they are still resolved. In addition, the validator checks whether the example from payload agrees with the schema defined in payload. In your case, your schema would not pass anyway - so Message Example Object.payload is not "any" in the sense of parser/validator.

magicmatatjahu avatar Aug 07 '23 13:08 magicmatatjahu

Right, so it's basically an arbitrary data (that's what any means for me) that needs to be validated later against Message.payload, but it's still just data. If the Message.payload is defined as empty schema {} then the validation would always pass. But that's not the issue here.

asyncapi: '2.6.0'
info:
  title: AsyncAPI
  version: '1.0.0'
channels:
  'foo':
    description: Bar.
    publish:
      message:
        oneOf:
          - $ref: '#/components/messages/Foo'
       
          
components:
  messages:
    Foo:
      name: Foo
      payload:
        $ref: "#/components/schemas/Bar"
      examples:
        - name: standard
          payload:
            after: 
              oneOf:
              - $ref: '#/components/messages/Foo'
              
  schemas:
    Bar: {}

The issue seem to be in following:

The parser tries to resolve the references and we do not exclude the refs in the payload's examples

This shouldn't happen, it seems that the tooling goes outside the spec here. But that's not what concerns me as well.

What concerns me is that the actual crash happens. In AsyncAPI studio you see the white screen, and after the reload you'll just see the splash screen indefinitely. You need to know how to delete localStorage to be able to work with https://studio.asyncapi.com/ again.

char0n avatar Aug 07 '23 13:08 char0n

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

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 :heart:

github-actions[bot] avatar Dec 06 '23 00:12 github-actions[bot]

Still reproducible in latest studio version.

char0n avatar Apr 04 '24 06:04 char0n