question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

needs_warnings not returning error code or writing to error log

See original GitHub issue

Usage of -W shall handle all warnings as errors and the sphinx-build executable shall return a non-zero value as error code. Also the usage of -w <file> shall write all warnings to a file.

This works incase of Sphinx warnings, but not for warnings created with needs_warnings. Because of this pipelines cannot be configured to break incase of needs_warnings.

To reproduce the problem, do the following steps

  1. Create needs_warnings in conf.py
  2. Create a need warning within any rST
  3. Execute sphinx-build as follows from a console
sphinx-build -M html docs _build -W --keep-going -w error.log  
  1. Observe need_warnings on the console
  2. Execute the following from the console
echo $?
  1. 0 is returned (a non-zero value is expected)
  2. Check the file error.log
  3. Only the following line is present
WARNING: Sphinx-Needs warnings were raised. See console / log output for details.

All needs_warnings are expected in the log.

Could it be that needs_warnings is always writing to stdout instead of stderror (even with -W)?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:15 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
danwoscommented, Oct 27, 2021

@haiyangToAI figured out the reason: The status code calculation happens in Sphinx far too early and is based on a warning_count. See https://github.com/sphinx-doc/sphinx/blob/81a4fd973d4cfcb25d01a7b0be62cdb28f82406d/sphinx/application.py#L345 As our warning-checks happen in the cleanup-phase, which gets executed by Sphinx after the status code calculation, the value for status_code may not be valid anymore.

@haiyangToAI is currently checking if we can make a dirty-hack and change this value on our own.

1reaction
twodropscommented, Oct 18, 2021

@haiyangToAI @danwos How can we conclude this topic? My current understanding from the above discussion is that, sphinx-needs warnings (or in general warnings thrown by sphinx extensions?) are treated differently compared to sphinx warnings. Is this an issue coming sphinx or sphinx-needs?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Errors not being written to error.log, inside a custom class
List most recent changed files: I figured that maybe a plugin or some code changes which debug-file to write to. · Boot server:...
Read more >
Functions, exceptions, return types and when to log your errors
Functions' purpose is to take your code from A (input) to B (return value, output). If something breaks between A and B, then...
Read more >
IIS Error Logs and Other Ways to Find ASP.Net Failed Requests
Instead of being frustrated from unknown ASP.NET errors, learn to troubleshoot errors using IIS error logs.
Read more >
USMT return codes - Windows Client - Microsoft Learn
This article describes User State Migration Tool (USMT) 10.0 return codes and error messages. Also included is a table listing the USMT ...
Read more >
error_log - Manual - PHP
Returns true on success or false on failure. If message_type is zero, this function always returns true , regardless of whether the error...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found