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

[BUG] operationMessagesUnambiguity rule throws error if operation or message is not a $ref. #1037

Open
2 tasks done
kamil1094 opened this issue Jul 9, 2024 · 1 comment · May be fixed by #1038
Open
2 tasks done
Labels
bug Something isn't working

Comments

@kamil1094
Copy link

Describe the bug.

I'm getting error like this:

cause: TypeError: Cannot read properties of undefined (reading 'startsWith')
        at /Users/kamil/workdir/tempBundler/node_modules/@asyncapi/parser/cjs/ruleset/v3/functions/operationMessagesUnambiguity.js:31:27
        at Array.forEach (<anonymous>)
        at /Users/kamil/workdir/tempBundler/node_modules/@asyncapi/parser/cjs/ruleset/v3/functions/operationMessagesUnambiguity.js:30:71
        at Object.function (/Users/kamil/workdir/tempBundler/node_modules/@stoplight/spectral-core/dist/ruleset/function.js:83:16)
        at lintNode (/Users/kamil/workdir/tempBundler/node_modules/@stoplight/spectral-core/dist/runner/lintNode.js:29:46)
        at cb (/Users/kamil/workdir/tempBundler/node_modules/@stoplight/spectral-core/dist/runner/runner.js:43:45)
        at mapped.<computed> (/Users/kamil/workdir/tempBundler/node_modules/@stoplight/spectral-core/dist/runner/runner.js:85:17)
        at _callbacks.<computed> (/Users/kamil/workdir/tempBundler/node_modules/nimma/dist/legacy/cjs/runtime/proxy-callbacks.js:31:9)
        at Scope.emit (/Users/kamil/workdir/tempBundler/node_modules/nimma/dist/legacy/cjs/runtime/scope.js:109:19)
        at $.operations.* (eval at query (/Users/kamil/workdir/tempBundler/node_modules/nimma/dist/legacy/cjs/core/index.js:66:71), <anonymous>:21:11)

after using .validate() method on AsyncAPI document that contains operations with channel and messages components specified like the one below(without using $ref)

sendBranchCreatedToAnalyticsExchange:
    action: send
    channel:
      address: analytics
      messages:
        branchCreatedMessage:
          title: Branch created message
          summary: Event fired after a branch is created.
          payload:
            title: Branch created payload
              - type: object
                properties:
                  type:
                    type: string
                    const: something.branch.created
                    example: something.branch.created
                required:
                  - type
      bindings:
        amqp:
          is: routingKey
          exchange:
            name: analytics
            type: topic
            durable: true
            autoDelete: false
            vhost: /
          bindingVersion: 0.3.0
    messages:
      - title: Branch created message
        summary: Event fired after a branch is created.
        payload:
          title: Branch created payload
          allOf:
            - title: Base API event message
              type: object
              properties:
                id:
                  type: string
                  description: Event ID.
                  pattern: '^evt_[0-9abcdefghjkmnpqrstvwxyz]{26}$'
                  example: evt_01h1s5z6vf2mm1mz3hevnn9va7
              required:
                - id
    bindings:
      amqp:
        cc:
          - branch.created
        ack: false
        bindingVersion: 0.3.0

Expected behavior

I can validate document containing operations like the one specified above without getting errors.

Screenshots

How to Reproduce

  1. Create AsyncAPI document with operation specified above
  2. Try to validate document using @asyncapi/parser .validate method

🥦 Browser

None

👀 Have you checked for similar open issues?

  • I checked and didn't find similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to work on this issue ?

Yes I am willing to submit a PR!

@kamil1094 kamil1094 added the bug Something isn't working label Jul 9, 2024
Copy link

github-actions bot commented Jul 9, 2024

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.

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

Successfully merging a pull request may close this issue.

1 participant