sphinx icon indicating copy to clipboard operation
sphinx copied to clipboard

sphinx-build exit code is 0 with ERRORS

Open g-chauvel opened this issue 3 years ago • 5 comments

Describe the bug

malformed table errors are reported as ERROR when running sphinx-build

source\a\a.rst:14: ERROR: Error parsing content block for the "list-table" directive: uniform two-level bullet list expected, but row 3 does not contain the same number of items as row 1 (4 vs 5). source\a\a.rst:35: ERROR: "list-table" widths do not match the number of columns in table (5). source\a\a.rst:51: ERROR: "list-table" widths do not match the number of columns in table (5).

but the exit code is 0

How to Reproduce

$ git clone https://github.com/g-chauvel/sphinx-doc
$ cd sphinx-doc
$ sphinx-build source build

Expected behavior

exit code is different from 0

Your project

https://github.com/g-chauvel/sphinx-doc

Screenshots

No response

OS

Windows 10

Python version

3.9.12

Sphinx version

4.5.0

Sphinx extensions

No response

Extra tools

No response

Additional context

No response

g-chauvel avatar Apr 28 '22 13:04 g-chauvel

Could you try -W option, please?

tk0miya avatar Apr 30 '22 18:04 tk0miya

I had. Warning, treated as error: , it stops on first one

g-chauvel avatar Apr 30 '22 18:04 g-chauvel

If you'd like to see the all of warnings (like CI), please use -W --keep-going. Then you'll see all warnings and errors, and will get the non-zero return code.

tk0miya avatar Apr 30 '22 18:04 tk0miya

I had a question on this one, what if there are a few WARNINGS which should not be treated as errors, in that case, how do we differentiate?

revati-naik avatar Jul 28 '23 21:07 revati-naik

I had a question on this one, what if there are a few WARNINGS which should not be treated as errors, in that case, how do we differentiate?

This is a very good question! We also have too many warnings that are irrelevant, that we cannot control (https://github.com/sphinx-doc/sphinx/issues/11325) or that are false positives. I was assuming I could skip reporting non-error-level warnings with -Q (--silent) and raise those of level ERROR with -W (--fail-on-warning). Apparently, this does not work (and it would not be good design). It would be good to have an option like --fail-on-warning-level=ERROR for which severity level should cause a failure, or an intuitive regular expression filter for which exact warnings should fail.

In the end, I found for myst_nb implements an extra nb_execution_raise_on_error. They must have had a reason (https://github.com/executablebooks/MyST-NB/issues/248) to build this despite Sphinx's mechanism.

aeisenbarth avatar Jun 26 '24 12:06 aeisenbarth

Closing due to inactivity. See also the new --exception-on-warning option with the change to --fail-on-warning.

A

AA-Turner avatar Jan 10 '25 01:01 AA-Turner