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

chained messages().get('xx').operations() call returns unrelated operations #938

Closed
linas-ipxo opened this issue Jan 12, 2024 · 2 comments
Closed
Labels

Comments

@linas-ipxo
Copy link

linas-ipxo commented Jan 12, 2024

Describe the bug

I have an asyncapi v3 doc, with two messages, and a distinct channel and a distinct operation per those messages.
i'm doing parsed.document.messages().get('msg1')?.operations().get('msg2')?.id() and msg2 shows up in msg1 operations collection.

Steps to reproduce the issue

Use the given asyncapi schema with the typescript snippet bellow.
Run as ts-node -T test.ts

asyncapi: "3.0.0"
info:
  title: Test 1
  version: 1.0.0

defaultContentType: application/json

channels:

  msg1:
    address: msg1
    messages:
      msg1:
        $ref: "#/components/messages/msg1"

  msg2:
    address: msg2
    messages:
      msg2:
        $ref: "#/components/messages/msg2"

operations:

  msg1:
    action: send
    channel:
      $ref: '#/channels/msg1'
    messages:
      - $ref: '#/channels/msg1/messages/msg1'

  msg2:
    action: send
    channel:
      $ref: '#/channels/msg2'
    messages:
      - $ref: '#/channels/msg2/messages/msg2'

components:

  messages:

    msg1:
      name: msg1
      title: Test 1 Msg 1
      summary: Test 1 Msg 1
      payload:
        type: object
        properties:
          msgdata:
            type: object
            properties:
              prop1:
                type: string
              prop2:
                type: integer

    msg2:
      name: msg2
      title: Test 1 Msg 2
      summary: Test 1 Msg 2
      payload:
        type: object
        properties:
          msgdata:
            type: object
            properties:
              prop1:
                type: string
              prop2:
                type: integer
import { Parser, fromFile } from "@asyncapi/parser";
import path from "path";

const parser = new Parser();

fromFile(parser, path.join(__dirname, 'test1.yml'))
.parse()
.then(parsed => {

  if (parsed.document === undefined) {
    throw new Error(`Unable to parse the given AsyncAPI document`);
  }

  console.log(`why does msg2 exist on msg1 operation? ${parsed.document.messages().get('msg1')?.operations().get('msg2')?.id()}`);
})
.catch((error: any) => {
  throw new Error(error);
});

Expected behavior

I would expect the chained method calls to filter the data based on the chain, meaning only msg1 operation should be visible when retrieved from .messages().get('msg1').operations() and msg2 should not be in the list.

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.

Copy link

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 May 12, 2024
@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant