Skip to content

Conversation

@Kartikayy007
Copy link

@Kartikayy007 Kartikayy007 commented Nov 4, 2025

Description

Fixes external file resolution via $ref that broke in v3.3.0. The issue was caused by incorrect object spread order in the ValidationService constructor.

Problem:
Since the 3.3.0 refactor, the ValidationService constructor has been merging __unstable config in the wrong order. The spread of parserOptions.__unstable?.resolver overwrites the resolver array, breaking local file reference resolution

BEFORE (bug):

__unstable: {
  resolver: {
    resolvers: [createHttpWithAuthResolver(), ...]  // Was added
  },
  ...parserOptions.__unstable?.resolver,  // Overwrites above
}

Solution:
Reordered spreads so base config is spread first, then custom resolvers are set last:

AFTER (fixed):

__unstable: {
  ...parserOptions.__unstable,
  resolver: {
    ...parserOptions.__unstable?.resolver,
    resolvers: [createHttpWithAuthResolver(), ...]  // Set last
  }
}

Testing:

  • Done All existing tests pass (200 passing)
  • Local file references now resolve correctly
  • GitHub resolver with auth still works

Related issue(s)

Fixes #1839

@changeset-bot
Copy link

changeset-bot bot commented Nov 4, 2025

🦋 Changeset detected

Latest commit: 9970b9e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@asyncapi/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Nov 4, 2025

Changeset has been generated for this PR as part of auto-changeset workflow.

Please review the changeset before merging the PR.
---
'@asyncapi/cli': patch
---

fix: correct resolver configuration merge in ValidationService

- 29c22f1: fix: correct resolver configuration merge in ValidationService

Fixes #1839
- b4529e5: test: add regression test for resolver config merge bug
- 8246049: test: add integration test for external file reference resolution

If you are a maintainer or the author of the PR, you can change the changeset by clicking here

Tip

If you don't want auto-changeset to run on this PR, you can add the label skip-changeset to the PR or remove the changeset and change PR title to something other than fix: or feat:.

@Shurtu-gal
Copy link
Collaborator

Thanks for finding the root cause @Kartikayy007. Could you possibly add a test targeting #1839 so that such scenarios don't happen later?

@Kartikayy007
Copy link
Author

Thanks for finding the root cause @Kartikayy007. Could you possibly add a test targeting #1839 so that such scenarios don't happen later?

ready for another review @Shurtu-gal

@Shurtu-gal
Copy link
Collaborator

@Kartikayy007 What I meant was having a set of asyncapi files with refs between them. That should provide us good sense of security.

@Kartikayy007
Copy link
Author

@Shurtu-gal please review, also please take a look at #1887 whenever you get time

Copy link
Collaborator

@Shurtu-gal Shurtu-gal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@github-project-automation github-project-automation bot moved this from To Triage to Backlog in CLI - Kanban Nov 9, 2025
@Kartikayy007
Copy link
Author

@Shurtu-gal ready to merge?

@Kartikayy007
Copy link
Author

/rtm

@neoandmatrix
Copy link
Contributor

neoandmatrix commented Nov 27, 2025

I believe after PR #1875 adding the custom resolver support, the spread of parserOptions.__unstable?.resolver was overwriting the custom resolvers array that was breaking local file reference resolution causing bug.

Just curious, PR #1875 was merged on Oct 27 but the issue #1839 was reported on Aug 22.

@sonarqubecloud
Copy link

@Kartikayy007
Copy link
Author

Just curious, PR #1875 was merged on Oct 27 but the issue #1839 was reported on Aug 22.

Thank you for that the bug came in the v3.3.0 itself not in the #1875 the PR inherited the issue, ill update the PR description

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

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

[BUG] external files in same directory are not resolved via $ref anymore, since v3.3.0

4 participants