Skip to content

server.py: logger is undefined in TuningProviderRegistry.get_merged()'s except handler (NameError instead of a log line) #899

Description

@byrongamatos

Found by pyflakes while carving server.py (R3b). Pre-existing — not a regression from the carve, and deliberately left alone there so the carve stays provably behaviour-neutral.

server.py (currently ~line 429, in TuningProviderRegistry.get_merged()):

except Exception:
    logger.exception("tuning provider %r raised during get_merged()", provider_id)

There is no logger in server.py — the module logger is log. So when a tuning provider actually does raise, the handler meant to swallow-and-report instead raises NameError: name 'logger' is not defined, which propagates out of get_merged().

The net effect is the opposite of what the handler is for: one misbehaving tuning provider takes down the merged-tunings call for everyone, and the exception you see names the wrong problem.

Fix

log.exception("tuning provider %r raised during get_merged()", provider_id)

Why it was never caught

Nothing exercises the failure path — no test has a tuning provider raise from get_merged(). A regression test should register a provider that throws and assert (a) get_merged() still returns the other providers' entries, and (b) the failure is logged.

Suggested guard

pyflakes catches this in one line (undefined name 'logger') and currently isn't in CI for server.py. Worth wiring in — this class of bug is invisible to the test suite precisely because it only lives on error paths.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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