You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When asyncapi diff is invoked with two documents and one of them fails to parse, the command exits with code 1 and prints a literal ValidationError: followed by no diagnostic body:
'invalid-file' is the file-not-found template; it renders There is no file or context with name "<path>". and ignores the err: field entirely. The other parse-failure path in the same file (the catch block at the bottom of run()) already uses 'parser-error' correctly, so this is an internal inconsistency rather than a design choice.
buildError emits an empty string for non-ParserError shapes - src/errors/validation-error.tsbuildError(err) only inspects err.title, err.detail, and err.validationErrors. The current ValidationService.parseDocument returns its error as a plain string ('Failed to parse document'), so none of those checks match and this.message stays ''. Even with fix CLI Specification #1 applied, the outer catch in run() wraps the original ValidationError in another one with type: 'parser-error', and buildError once again sees no title / detail / validationErrors - so the message is still empty by the time oclif prints it.
The combination of these two bugs is what produces the bare ValidationError: symptom.
Related prior art
[BUG] Diff command doesn't work when circular reference #2093 - BUG: Diff command doesn't work when circular reference. Different code path (circular $ref throws a TypeError during JSON serialisation rather than failing the parser's success check), but same general class: parse-time failures aren't surfaced gracefully by diff.
Symptom
When
asyncapi diffis invoked with two documents and one of them fails to parse, the command exits with code1and prints a literalValidationError:followed by no diagnostic body:This makes it impossible for users (and CI logs) to know why parsing failed.
Reproduction
Repo is reproducible against
masterusing the fixtures shipped in the repo:Confirmed on
master(current 6.x) and v5.0.5.Root cause
Two contributing bugs in the parser-failure path:
Wrong ValidationError type for parse failures -
src/apps/cli/commands/diff.tsparseDocumentsconstructs:'invalid-file'is the file-not-found template; it rendersThere is no file or context with name "<path>".and ignores theerr:field entirely. The other parse-failure path in the same file (the catch block at the bottom ofrun()) already uses'parser-error'correctly, so this is an internal inconsistency rather than a design choice.buildErroremits an empty string for non-ParserError shapes -src/errors/validation-error.tsbuildError(err)only inspectserr.title,err.detail, anderr.validationErrors. The currentValidationService.parseDocumentreturns its error as a plain string ('Failed to parse document'), so none of those checks match andthis.messagestays''. Even with fix CLI Specification #1 applied, the outercatchinrun()wraps the originalValidationErrorin another one withtype: 'parser-error', andbuildErroronce again sees notitle/detail/validationErrors- so the message is still empty by the time oclif prints it.The combination of these two bugs is what produces the bare
ValidationError:symptom.Related prior art
BUG: Diff command doesn't work when circular reference. Different code path (circular$refthrows aTypeErrorduring JSON serialisation rather than failing the parser'ssuccesscheck), but same general class: parse-time failures aren't surfaced gracefully bydiff.Proposed fix
I have a PR ready that:
parseDocumentsfailure branch from'invalid-file'to'parser-error', mirroring the existing usage in therun()catch block.buildErrorso any error shape (string, genericError, or undefined) produces a non-empty message instead of''.ValidationError(no test file exists today) and an integration test fordiffagainst the parse-failure path.I'll open it shortly and link it here.
Environment
@asyncapi/climaster (current 6.x) and v5.0.5