Skip to content

[BUG] bundle creates invalid document (refs) #1989

Description

@black-snow

Describe the bug.

asyncapi bundle creates invalid documents.

main.yaml

asyncapi: 3.0.0
info:
  title: demo
  version: '1'
operations:
  A:
    $ref: "./_sub.yaml#/components/operations/A"
channels:
  A:
    $ref: "./_sub.yaml#/components/channels/A"

_sub.yaml

components:
  operations:
    A:
      action: send
      channel:
        $ref: '#/components/channels/A'
      messages:
        - $ref: '#/components/channels/A/messages/A'
  channels:
    A:
      messages:
        A:
          $ref: '#/components/messages/A'
  messages:
    A:
      payload:
        type: object
asyncapi validate main.yaml
asyncapi bundle ./main.yaml --output final.yml
asyncapi validate final.yml

produced invalid output:

asyncapi: 3.0.0
info:
  title: demo
  version: '1'
channels:
  A:
    messages:
      A:
        payload:
          type: object
operations:
  A:
    action: send
    channel:
      $ref: '#/components/channels/A'
    messages:
      - $ref: '#/components/channels/A/messages/A'

Expected behavior

It should've either updated the refs to root or moved the channels/ops/messages to components (if allowed).

Screenshots

How to Reproduce

see above

🖥️ Device Information [optional]

  • Operating System (OS): macOS latest
  • Browser: WF
  • Browser Version: latest

👀 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 ?

No, someone else can work on it

Activity

  1. black-snow commented on Jan 26, 2026

    @black-snow
    Author

    When I move channels and operations to root the produced doc is fine.

  2. Varadraj75 commented on Feb 1, 2026

    @Varadraj75
    Contributor

    Hey @Shurtu-gal @Souvikns @AayushSaini101 ,

    Edit: My earlier comment was about asyncapi optimize, which is not relevant to this issue — thanks for flagging that.

    For asyncapi bundle, the problem is that the bundled output keeps $refs pointing to #/components/... while the actual channels, operations, and messages are moved to the root, resulting in an invalid document.

    The bundler should either rewrite $refs to the new root paths or keep the referenced definitions under components consistently.

  3. black-snow commented on Feb 2, 2026

    @black-snow
    Author

    @Varadraj75 did you mean to post this here (vs. in my optimize bug ticket)? This issue is about bundling.

  4. Varadraj75 commented on Feb 2, 2026

    @Varadraj75
    Contributor

    @black-snow
    Thanks for the clarification — you’re right, my earlier comment was about optimize, not bundle.

    For bundling, the issue seems to be that $refs still point to #/components/... even though the bundled output moves channels/operations/messages to the root, making the document invalid.

    The bundler should either rewrite those $refs to the new root paths or keep the definitions under components consistently.

  5. Demiserular commented on Feb 15, 2026

    @Demiserular

    Should i work on it?

  6. github-actions commented on Jun 18, 2026

    @github-actions
    Contributor

    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 ❤️

  7. tanav29 commented on Sep 3, 2026

    @tanav29

    Should I try this issue?

  8. coderxaditya commented on Oct 6, 2026

    @coderxaditya

    I'd like to work on this. I can still reproduce it on CLI 6.2.0, and also with the latest @asyncapi/bundler (1.0.2), so it isn't fixed yet.

    I looked into it and the issue is in the bundler, not the CLI itself. For v3 documents the bundler intentionally keeps refs like operations.*.channel and operations.*.messages as refs. But when the operation is pulled in from another file, those refs still point to that file's own #/components/..., and after bundling they point to paths that don't exist in the output. I think asyncapi/bundler#237 has the same root cause, just with channels.*.servers.

    Since the bundler is planned to move into the CLI (asyncapi/bundler#235), where would you prefer the fix: in asyncapi/bundler now, or after the migration in this repo? Happy to go either way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstale

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions