Skip to content

Conversation

@AayushSaini101
Copy link
Collaborator

Resolves: #1796

  • Create a custom resolver to fetch the reference from the private repo
  • Add new command auth add for storing the repo name and repo token.
  • Tests and documents need to be updated

@changeset-bot
Copy link

changeset-bot bot commented Oct 20, 2025

🦋 Changeset detected

Latest commit: da60cf0

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 Minor

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 Oct 20, 2025

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

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

feat: add new custom resolver to fetch the reference from private repo

- 88ceb3d:  add new custom resolver to fetch the reference from private repo
- 4974358: Update src/domains/services/validation.service.ts

Co-authored-by: Fran Méndez <fmvilas@gmail.com>
- c764ee6: update instruction in the test case for the validation success
- 2b9457f: fix test-cases
- 86bbfc4: fix lint issue across the project
- 6813ef0: Update 1875.md

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:.

asyncapi-bot pushed a commit to AayushSaini101/cli that referenced this pull request Oct 20, 2025
asyncapi-bot pushed a commit to AayushSaini101/cli that referenced this pull request Oct 20, 2025
const result = await validationService.validateDocument(specFile, options);

// The validation succeeds but the document is invalid due to unresolved ref
expect(result.success).to.equal(true);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@fmvilas success is true defines the command is successfully executed

Copy link
Member

Choose a reason for hiding this comment

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

The validation succeeds but the document is invalid

This is tricky, isn't it? How would you justify this decision to another developer whenever they get result.success ==== true but the document is invalid? If that's the case, we can't rely on result.success to see if the document is valid or not.

Also, think about it, "validation succeeds" but it's "invalid" (i.e., not valid). Isn't it a contradiction?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@fmvilas, actually, the success is defined complete execution of the command; it is independent of whether the document is valid or not.

If the document is invalid in, we can see a status field that shows data: { status: invalid}, we can check in the following the pic : )
image

I have added a comment on the test cases to avoid confusion : )

@fmvilas
Copy link
Member

fmvilas commented Oct 20, 2025

Please next time don't force-push 🙏 It completely removes the whole history and makes it harder to review.

const result = await validationService.validateDocument(specFile, options);

// The validation succeeds but the document is invalid due to unresolved ref
expect(result.success).to.equal(true);
Copy link
Member

Choose a reason for hiding this comment

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

The validation succeeds but the document is invalid

This is tricky, isn't it? How would you justify this decision to another developer whenever they get result.success ==== true but the document is invalid? If that's the case, we can't rely on result.success to see if the document is valid or not.

Also, think about it, "validation succeeds" but it's "invalid" (i.e., not valid). Isn't it a contradiction?

@github-project-automation github-project-automation bot moved this from To Triage to Backlog in CLI - Kanban Oct 20, 2025
@asyncapi-bot asyncapi-bot added the bounty AsyncAPI Bounty program related label label Oct 21, 2025
@aeworxet
Copy link
Contributor

@asyncapi/bounty_team

@aeworxet aeworxet moved this to In Progress in Bounty Program Oct 21, 2025
@Shurtu-gal
Copy link
Collaborator

Shurtu-gal commented Oct 24, 2025

@fmvilas

Also, think about it, "validation succeeds" but it's "invalid" (i.e., not valid). Isn't it a contradiction?

So, how all services currently work, is if there is a uncaught or unresolveable error it returns an error response. The success basically means that the service ran properly. Inside the data the status of the document is shown if its valid | invalid.

This can be changed though if you have some suggestions.

You can see it here:
https://github.com/asyncapi/cli/blob/master/src/domains/services/base.service.ts#L1-L25

@AayushSaini101
Copy link
Collaborator Author

/u

@AayushSaini101
Copy link
Collaborator Author

/u

Souvikns
Souvikns previously approved these changes Oct 25, 2025
@fmvilas
Copy link
Member

fmvilas commented Oct 27, 2025

@fmvilas

Also, think about it, "validation succeeds" but it's "invalid" (i.e., not valid). Isn't it a contradiction?

So, how all services currently work, is if there is a uncaught or unresolveable error it returns an error response. The success basically means that the service ran properly. Inside the data the status of the document is shown if its valid | invalid.

This can be changed though if you have some suggestions.

You can see it here: https://github.com/asyncapi/cli/blob/master/src/domains/services/base.service.ts#L1-L25

I see it's not an issue of this PR but it's definitely weird, don't you think so? Think about the devs than don't know the code base and are only using the CLI.

fmvilas
fmvilas previously approved these changes Oct 27, 2025
Copy link
Member

@fmvilas fmvilas left a comment

Choose a reason for hiding this comment

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

Let's get this merged 🙂

cc @asyncapi/bounty_team

@AayushSaini101
Copy link
Collaborator Author

/u

@AayushSaini101 AayushSaini101 dismissed stale reviews from fmvilas and Souvikns via 6813ef0 October 27, 2025 09:27
@sonarqubecloud
Copy link

@Shurtu-gal
Copy link
Collaborator

I see it's not an issue of this PR but it's definitely weird, don't you think so? Think about the devs than don't know the code base and are only using the CLI.

  • Agree with the weirdness part, any suggestions on how it could be improved.
  • Regarding the devs statment, this success or failure is not shown to CLI users. If the doc is invalid it just shows the doc is invalid. The service output is irrelevant here I suppose?
image

@AayushSaini101
Copy link
Collaborator Author

/rtm

@asyncapi-bot asyncapi-bot merged commit 70761f0 into asyncapi:master Oct 27, 2025
24 checks passed
@github-project-automation github-project-automation bot moved this from Backlog to Done in CLI - Kanban Oct 27, 2025
@github-project-automation github-project-automation bot moved this from In Progress to Completed in Bounty Program Oct 27, 2025
@fmvilas
Copy link
Member

fmvilas commented Oct 27, 2025

Yeah, if CLI users are not suffering it, that's fine. However, I think it's a fine line. If you're not aware of this difference, it's easy to push wrong code in the future.

As per how to fix it, I'd just make it fail. If something doesn't resolve, trigger the error. A call to a method called validate() should return success: true if, and only if, the document is valid. If a reference is not resolved, then the document isn't valid, right? Or, at the very least, we couldn't finish the validation. This reminds me of people responding with 200 OK and { "error": "..." } in HTTP APIs. If there's an error, is not OK, so don't use the 200 code. Same here.

The above is if you want to preserve the current API. I'd go one step beyond and simply remove the success field altogether. If the call to validate() doesn't throw an error, it means it's valid. Otherwise, you can catch the error(s).

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

Labels

bounty AsyncAPI Bounty program related label ready-to-merge

Projects

Status: Completed
Status: Done

Development

Successfully merging this pull request may close these issues.

[FEATURE] Pass authentication/authorization to $ref HTTP resolvers

6 participants