-
-
Notifications
You must be signed in to change notification settings - Fork 209
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] Inaccurate error in asyncapi optimize
#1626
Comments
@derberg I believe the issue is related to a validation error, which is causing the misleading "file not found" message. I'd like to work on this and resolve the issue. Can you please assign it to me? |
Fixing Misleading Validation Error in AsyncAPI CLIHello @derberg, @AayushSaini101 I’ve investigated the error you described, traced through the code, and identified the root cause. Let me walk you through the fix! 🚀 🧩 ProblemIn the error report, the CLI threw this misleading message:
However, the validation already caught other issues, meaning the file path was correct. The misleading message originated from this section: let optimizer: Optimizer;
let report: Report;
try {
optimizer = new Optimizer(this.specFile.text());
report = await optimizer.getReport();
} catch (err) {
this.error(
new ValidationError({
type: 'invalid-file',
filepath: filePath,
})
);
} In the ✅ SolutionI changed the error type from catch (err) {
this.error(
new ValidationError({
type: 'parser-error',
err: err,
})
);
} This way, instead of falsely claiming the file doesn’t exist, the CLI will display detailed parsing errors — giving users accurate feedback! 🎯 🔧 ResultWith this fix, the CLI now correctly shows parser-related errors, helping users debug their AsyncAPI specs more effectively. I’ve pushed the fix and raised a PR. Could you please review it when you have a moment? 🙌 Thanks so much! Let me know if you’d like me to tweak the wording or add anything! ✌️ |
@AayushSaini101 This issue has been resolved by the PR #1634 and can be close successfully. Thanks. |
Describe the bug.
I have AsyncAPI document with broken message reference in line 39:
When I run:
asyncapi optimize ./asyncapi-client.yaml
I get error likeThe array with validation error info is correct. I mean, maybe object should be rendered instead of
[Object]
but in general it is ok.The problem is with the last line:
ValidationError: There is no file or context with name "./asyncapi-client.yaml".
This error just doesn't make sense, the path reference was correct, otherwise validation would not catch the error with the message
Expected behavior
Remove the misleading error message
Screenshots
no
How to Reproduce
already described in description
🥦 Browser
None
👀 Have you checked for similar open issues?
🏢 Have you read the Contributing Guidelines?
Are you willing to work on this issue ?
No, someone else can work on it
The text was updated successfully, but these errors were encountered: