studio icon indicating copy to clipboard operation
studio copied to clipboard

Referencing message inside a message catastrophically breaks the website

Open Ksisa opened this issue 11 months ago • 9 comments

I was playing around with message extensions (on hosted website https://studio.asyncapi.com/), thinking I could reference the response message inside the message like so

components:
  messages:
    TradeMessageServer:
      name: Trade Message (server)
      title: Trade Message (server)
      description: A message containing trade data
      payload:
        title: TradePayloadServer
        type: object
        properties:
          operation:
            type: string
            const: Trade
          data:
            $ref: "#/components/schemas/TradeServer"
        additionalProperties: false
        required:
          - operation
          - data
      x-response: 
        $ref: "#/components/messages/TradeMessageClient" #this breaks it

If you enter a valid message into the x-response tag, it completely breaks the website, so much that even ctrl+f5 doesn't work. You need to go into the dev tools and clear the local storage to get it to work again.

image

I understand this is likely to be invalid, but I also doubt the website should break in such a catastrophic way.

Ksisa avatar Aug 11 '23 13:08 Ksisa

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.

github-actions[bot] avatar Aug 11 '23 13:08 github-actions[bot]

@Ksisa I have tried to reproduce the error with this file:

asyncapi: '2.6.0'
info:
  title: Account Service
  version: 1.0.0
  description: This service is in charge of processing user signups
channels:
  user/signedup:
    subscribe:
      message:
        $ref: '#/components/messages/TradeMessageServer'
components:
  messages:
    TradeMessageServer:
      name: Trade Message (server)
      title: Trade Message (server)
      description: A message containing trade data
      payload:
        title: TradePayloadServer
        type: object
        properties:
          operation:
            type: string
            const: Trade
        additionalProperties: false
        required:
          - operation
          - data
      x-response: 
        $ref: "#/components/messages/TradeMessageClient" #this breaks it
    TradeMessageClient:
      name: Trade Message (server)
      title: Trade Message (server)
      description: A message containing trade data
      payload:
        title: TradePayloadServer
        type: object
        properties:
          operation:
            type: string
            const: Trade
        additionalProperties: false
        required:
          - operation
          - data

but it seems to be working fine. can you provide a full example of an AsyncAPI file that causes it to fail?

KhudaDad414 avatar Aug 16 '23 09:08 KhudaDad414

@Ksisa is the issue resolved?

KhudaDad414 avatar Aug 24 '23 16:08 KhudaDad414

same here, lost all data

Afler avatar Aug 25 '23 09:08 Afler

@Ksisa is the issue resolved?

Sorry, I'm holiday, I'll send the erroring spec when I'm back

Ksisa avatar Aug 25 '23 15:08 Ksisa

@KhudaDad414 turns out I made a mistake, it happens when you reference the same message within the message:

asyncapi: '2.6.0'
info:
  title: Account Service
  version: 1.0.0
  description: This service is in charge of processing user signups
channels:
  user/signedup:
    subscribe:
      message:
        $ref: '#/components/messages/TradeMessageServer'
components:
  messages:
    TradeMessageServer:
      name: Trade Message (server)
      title: Trade Message (server)
      description: A message containing trade data
      payload:
        title: TradePayloadServer
        type: object
        properties:
          operation:
            type: string
            const: Trade
        additionalProperties: false
        required:
          - operation
          - data
      x-response: 
        $ref: "#/components/messages/TradeMessageServer" #this breaks it

Ksisa avatar Aug 29 '23 15:08 Ksisa

Hey @KhudaDad414 @Ksisa as far as I looked into the issue this looks to be a AsyncAPI-react library issue. It seems that the infinite recursive call to message ref is leading to a Stack overflow. If it seems legit I can report it upstream.

ashmit-coder avatar Feb 28 '24 11:02 ashmit-coder

@ashmit-coder As far as the studio is concerned, it shouldn't break. maybe show some kind of an error when things like this happen. maybe from parser or asyncapi-react. 🤔

KhudaDad414 avatar Mar 05 '24 12:03 KhudaDad414

@ashmit-coder As far as the studio is concerned, it shouldn't break. maybe show some kind of an error when things like this happen. maybe from parser or asyncapi-react. 🤔

Yeah but I ran the code on https://asyncapi.github.io/asyncapi-react/

As well and that resulted in it breaking as well. So 🤔

ashmit-coder avatar Mar 05 '24 15:03 ashmit-coder