Opus finding
Log filter mutates levelno but record may have already been level-filtered
lowbugmedium
- agent/tools/markets.py:30-41
logging filters run after the logger's effective level check but before handler-level checks. Mutating record.levelno from ERROR to INFO inside a filter does not propagate to logger.isEnabledFor or to handler level filtering that already passed; downstream handlers will still emit the record at whatever they accepted it as. More importantly, if any handler is configured to filter by levelno (some Lambda handlers do), this in-place mutation can produce inconsistent state. The cleaner pattern is to return False to drop, or to use a Filter that returns False for the specific marker.
Recommendation
Return False to suppress the record entirely, or attach the filter to handlers and reissue via logger.info. Avoid mutating LogRecord level fields post-dispatch.