parser-js icon indicating copy to clipboard operation
parser-js copied to clipboard

Parser do not validate if channel that is referenced in reply with location has `null` in address

Open derberg opened this issue 2 years ago • 11 comments

Like in the title

So I have such document

asyncapi: 3.0.0
info:
  title: Account Service
  version: 1.0.0
  description: This service is in charge of processing user signups
channels:
  replyChannel:
    address: user/signedup
    messages:
      UserSignedUp:
        $ref: '#/components/messages/UserSignedUp'
  userSignedup:
    address: user/signedup
    messages:
      UserSignedUp:
        $ref: '#/components/messages/UserSignedUp'
operations:
  sendUserSignedup:
    action: send
    channel:
      $ref: '#/channels/userSignedup'
    messages:
      - $ref: '#/channels/userSignedup/messages/UserSignedUp'
    reply:
      channel: 
        $ref: '#/channels/replyChannel'
      address:
        location: '$message.header#/REPLY_TOPIC'
components:
  messages:
    UserSignedUp:
      payload:
        type: object
        properties:
          displayName:
            type: string
            description: Name of the user
          email:
            type: string
            format: email
            description: Email of the user

it should not be a valid document. Spec explicitly defines that if in reply you specify dynamic location of the response address (reply.address) then referenced channel must have undefined address or address: null

derberg avatar Oct 12 '23 13:10 derberg

We need a new spectral rule for this. To solve this issue:

  • Create a new spectral rule that targets v3: https://github.com/asyncapi/parser-js/blob/next-major-spec/src/ruleset/ruleset.ts#L10
  • Create a new spectral function similar to: https://github.com/asyncapi/parser-js/blob/d614ffa239f1daae6f343a8aabf24a55c99800bd/src/ruleset/functions/unusedComponent.ts#L7
  • Make the function match all operations that define reply and address to check for whether the associated channel has address with null value.
  • Adjust the spectral rule to use the new spectral function.

This issue is marked as good first issue, but it's a hard one!

Remember to target the next-major-spec branch.

jonaslagoni avatar Nov 09 '23 19:11 jonaslagoni

/gfi typescript

jonaslagoni avatar Nov 09 '23 19:11 jonaslagoni

You can go ahead and work on it @Min2who, we dont really assign issues 😄

jonaslagoni avatar Nov 23 '23 19:11 jonaslagoni

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 Mar 23 '24 00:03 github-actions[bot]

hey @jonaslagoni is this still relevant?

ashmit-coder avatar Mar 29 '24 13:03 ashmit-coder

Hey @smoya is this issue still valid because in above asyncapi document the studio gives this error Operation message does not belong to the specified channel.

ibishal avatar Jun 15 '24 09:06 ibishal

Hey @smoya is this issue still valid because in above asyncapi document the studio gives this error Operation message does not belong to the specified channel.

@ibishal I fixed the example. Now you will see Studio (or directly the Parser-JS) won't complain about anything when it should.

smoya avatar Jun 17 '24 12:06 smoya

@ibishal I fixed the example. Now you will see Studio (or directly the Parser-JS) won't complain about anything when it should.

@smoya the example defined in the issue still gives the same error

ibishal avatar Jun 20 '24 17:06 ibishal

@ibishal I fixed the example. Now you will see Studio (or directly the Parser-JS) won't complain about anything when it should.

@smoya the example defined in the issue still gives the same error

For some reason, didn't copy the right one. Now I promise it works, please check again 😆

smoya avatar Jun 21 '24 08:06 smoya

For some reason, didn't copy the right one. Now I promise it works, please check again 😆

It worksss but @smoya the spec with the issue mismatch

ibishal avatar Jun 21 '24 08:06 ibishal

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 Oct 20 '24 00:10 github-actions[bot]