Skip to content

fix(dita): report dita's own error output instead of just the exit status - #1141

Open
VXNCXNX wants to merge 1 commit into
vale-cli:v3from
VXNCXNX:fix/dita-surface-stderr
Open

fix(dita): report dita's own error output instead of just the exit status#1141
VXNCXNX wants to merge 1 commit into
vale-cli:v3from
VXNCXNX:fix/dita-surface-stderr

Conversation

@VXNCXNX

@VXNCXNX VXNCXNX commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

lintDITA wires the dita command's stderr into a buffer and then never reads it, so a failed conversion shows only the exit status:

E100 [a.dita] Runtime error

exit status 1

The actual diagnostic — DTD resolution failures, malformed maps, missing conrefs — is discarded.

This returns the captured stderr, the way lintXML already does at internal/lint/xml.go:45:

E100 [a.dita] Runtime error

[DOTX046E][ERROR] The DTD could not be resolved.

Fixes #578

The fallback matters

Copying lintXML verbatim (errors.New(eut.String())) would regress the case where dita exits non-zero without writing anything — the error body would be blank, which is worse than today. So the exit status is kept as a fallback:

dita behaviour before after
writes to stderr, exits 1 exit status 1 the stderr text
exits 1 silently exit status 1 exit status 1
succeeds unchanged unchanged

Verified both failing cases with a stub dita on PATH.

Worth being precise about the scope: dita writes some diagnostics to stdout rather than stderr, and those still will not appear. Only cmd.Stderr is captured here, and I did not want to conflate the two streams into one buffer since that would change what the message looks like in the common case.

go test ./internal/... passes. The DITA e2e cases are gated behind requires: dita and all cover the success path, which this does not touch.

…atus

lintDITA captured the dita command's stderr into a buffer and never read
it, so a failed conversion showed only 'Runtime error / exit status 1'
and every diagnostic was discarded.

Return the captured stderr, as lintXML already does, falling back to the
exit status when dita fails without writing anything.

Fixes vale-cli#578
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Runtime error for the dita file

1 participant