Repository navigation
Open
Description
Describe the bug.
In ValidationService.buildParserWithAllWarningsSuppressed (src/domains/services/validation.service.ts#L327-L341), --suppressAllWarnings collects d.code from every diagnostic returned by this.parser.validate(...) without filtering for warning severity (d.severity === DiagnosticSeverity.Warning), and passes all of them directly to this.buildCustomParser(allRuleNames):
private async buildParserWithAllWarningsSuppressed(
specFile: Specification
): Promise<Parser> {
const diagnostics = await this.parser.validate(specFile.text(), {
source: specFile.getSource(),
});
const allRuleNames = Array.from(
new Set(
diagnostics
.map((d) => d.code)
.filter((c): c is string => typeof c === 'string'),
),
);
return this.buildCustomParser(allRuleNames);
}This causes two distinct failures when asyncapi validate <spec> --suppressAllWarnings (or validationService.validateDocument(spec, { suppressAllWarnings: true })) is run on an invalid specification:
- Schema and resolution
Errorrules are silently turned'off', causing invalid documents to pass validation with exit code0:
When a document hasError-severity Spectral rules (such asasyncapi2-schemas,asyncapi3-schemas, orasyncapi-document-resolvedintest/fixtures/specification-invalid.yml),buildParserWithAllWarningsSuppressedturns those error rules'off'. Re-parsing then returnsstatus: 'valid'anddiagnostics: [](File ... is valid!) with exit code0. - Documents with unresolvable
$refs crash withCannot extend non-existing rule: "invalid-ref":
When a document triggers a parser diagnostic whosecodeis not an extendable Spectral rule in the base ruleset (such asinvalid-ref),this.buildCustomParser(allRuleNames)throwsError: Cannot extend non-existing rule: "invalid-ref"instead of filtering viabuildParserWithSpecificWarningsSuppressed.
Expected behavior
--suppressAllWarningsshould only suppress rules withd.severity === DiagnosticSeverity.Warning(DiagnosticSeverity.Error,Information, andHintdiagnostics must not have their rules disabled).buildParserWithAllWarningsSuppressedshould delegate tothis.buildParserWithSpecificWarningsSuppressed(warningRuleNames)(or returnthis.parserwhenwarningRuleNames.length === 0) so any non-ruleset diagnostic code never throwsCannot extend non-existing rule.
Screenshots
Not applicable.
How to Reproduce
From the root of asyncapi/cli:
npx ts-node -T -r tsconfig-paths/register -e '
import { ValidationService } from "./src/domains/services/validation.service";
import { load, Specification } from "./src/domains/models/SpecificationFile";
(async () => {
const svc = new ValidationService();
// 1. Invalid spec (missing required fields / unresolved errors) passes as "valid"
const invalidSpec = await load("./test/fixtures/specification-invalid.yml");
console.log("1. specification-invalid.yml without flag:", (await svc.validateDocument(invalidSpec)).data?.status);
// -> "invalid"
console.log("2. specification-invalid.yml with suppressAllWarnings:", (await svc.validateDocument(invalidSpec, { suppressAllWarnings: true })).data?.status);
// -> "valid" (0 diagnostics!)
// 2. Broken $ref crashes with "Cannot extend non-existing rule: \"invalid-ref\""
const brokenRefSpec = new Specification(JSON.stringify({
asyncapi: "2.6.0",
info: { title: "Test", version: "1.0.0" },
channels: {
"user/signedup": {
subscribe: { message: { $ref: "./non-existent.yaml#/messages/UserSignedUp" } }
}
}
}), { filePath: "/tmp/spec.json" });
console.log("3. brokenRefSpec with suppressAllWarnings:", await svc.validateDocument(brokenRefSpec, { suppressAllWarnings: true }));
// -> { success: false, error: "Cannot extend non-existing rule: \"invalid-ref\"" }
})();
'🖥️ Device Information [optional]
- Operating System (OS): Linux
- Node.js: v24.11+
@asyncapi/cli: currentmaster(v6.2.3)
👀 Have you checked for similar open issues?
- I checked and didn't find similar issue
🏢 Have you read the Contributing Guidelines?
- I have read the Contributing Guidelines
Are you willing to work on this issue ?
Yes I am willing to submit a PR!
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
- StatusShow more project fieldsTo Triage
Activity
github-actions commentedon Nov 7, 2026
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.
hoanle0126 commentedon Nov 7, 2026
I have opened #2341 with a fix and regression tests for this issue.