Skip to content

Logging: log_warning() missing 2 required positional arguments (subtype and location) #1493

@oxmb

Description

@oxmb

Bug Description

When building Sphinx documentation with sphinx-needs 5.1.0, the build fails with an extension error during the warnings processing phase.

Error Message

  Extension error (sphinx_needs.warnings):
  Handler <function process_warnings at 0x7fc590f29580> for event 'build-finished' threw an exception (exception: log_warning() missing 2 required positional arguments: 'subtype' and 'location')

Environment

  • Sphinx version: 8.1.3
  • sphinx-needs version: 5.1.0
  • Python version: 3.13.6
  • Operating System: Linux/Debian

Configuration

The issue occurs when needs_warnings is misconfigured in conf.py:

needs_warnings = {
    'need_missing_id': True,
    'need_invalid_id': True,
}

Expected Behavior

The documentation should build successfully with warnings properly handled and logged.

Actual Behavior

The build completes but throws an extension error at the end during warnings processing, indicating that the log_warning() function is being called with an incompatible signature.

Workaround

Temporarily disabling the warnings configuration resolves the issue:

  # needs_warnings = {
  #     'need_missing_id': True,
  #     'need_invalid_id': True,
  # }

Root Cause

This appears to be a compatibility issue where sphinx-needs 5.1.0 is at some point calling log_warning() with an older API signature, but the current Sphinx version (8.1.3) expects additional parameters
(subtype and location).

Additional Context

  • The documentation builds successfully despite the error
  • Only the warnings processing is affected
  • All sphinx-needs directives (req, spec, impl, test) work correctly
  • Custom extra options are processed without issues

Reproduction Steps

  1. Install sphinx-needs 5.1.0 with Sphinx 8.1.3
  2. Configure needs_warnings in conf.py
  3. Run sphinx-build with any sphinx-needs directives
  4. Observe the extension error during build completion

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions