Skip to content

fix(gateway): restore lazy import of RedactingFormatter after #7991 - #8101

Closed
fancydirty wants to merge 1 commit into
NousResearch:mainfrom
fancydirty:fix/gateway-redacting-formatter-import
Closed

fix(gateway): restore lazy import of RedactingFormatter after #7991#8101
fancydirty wants to merge 1 commit into
NousResearch:mainfrom
fancydirty:fix/gateway-redacting-formatter-import

Conversation

@fancydirty

Copy link
Copy Markdown
Contributor

Add lazy from agent.redact import RedactingFormatter import back to the stderr handler setup block that was orphaned by the component-separated logging refactor.

Fixes #8090

…earch#7991

The import was removed by the component-separated logging refactor (NousResearch#7991),
but the stderr handler block added in bacc86d still references it.
Add the lazy import back at the point of use.

Fixes NousResearch#8090
Copilot AI review requested due to automatic review settings April 12, 2026 02:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Restores a lazy import of RedactingFormatter in gateway.run.start_gateway() to prevent a startup crash introduced by the component-separated logging refactor (#7991), matching the project’s existing lazy-import pattern and fixing #8090.

Changes:

  • Reintroduce from agent.redact import RedactingFormatter inside the verbosity is not None stderr-handler setup block.
Comments suppressed due to low confidence (1)

gateway/run.py:8477

  • Consider adding a regression test that exercises the verbosity is not None branch of start_gateway() to ensure the stderr handler setup does not raise (e.g., NameError) and that the handler’s formatter is a RedactingFormatter. There are already tests covering other start_gateway() paths, but none validate this verbosity-driven stderr configuration.
    if verbosity is not None:
        from agent.redact import RedactingFormatter
        _stderr_level = {0: logging.WARNING, 1: logging.INFO}.get(verbosity, logging.DEBUG)
        _stderr_handler = logging.StreamHandler()
        _stderr_handler.setLevel(_stderr_level)
        _stderr_handler.setFormatter(RedactingFormatter('%(levelname)s %(name)s: %(message)s'))

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@fancydirty

Copy link
Copy Markdown
Contributor Author

Upstream main has already restored the from agent.redact import RedactingFormatter lazy import. This PR is now redundant — closing.

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.

NameError: name 'RedactingFormatter' is not defined crashes gateway on startup after #7991

2 participants