Skip to content

Crash in RotatingFileHandler when --neuron.events_retention_size is set via CLI #154

@FairyPigDev

Description

@FairyPigDev

Summary

--neuron.events_retention_size is declared with type=str in allways/utils/config.py:44-49,
but the default is an int and the value is passed to RotatingFileHandler(maxBytes=...). Any operator who passes the flag on the CLI gets a string, which crashes the stdlib rollover check:

TypeError: '>' not supported between instances of 'str' and 'int'

Impact

  • Default path (operator doesn't pass the flag): works. default=2 * 1024 * 1024 * 1024 is already an int, so maxBytes is typed correctly.
  • Tuned path (operator passes --neuron.events_retention_size <value>): the value becomes a str, and RotatingFileHandler.shouldRollover() does self.maxBytes > 0 on every log write. The first rollover — which happens as soon as the event log crosses the threshold — raises TypeError and kills the logger thread (or propagates, depending on the neuron's event loop).

Latent because most operators rely on the 2 GB default, so the bug only surfaces for operators who deliberately tune event retention.

Reproduction

import argparse

parser = argparse.ArgumentParser()
parser.add_argument(
    '--neuron.events_retention_size',
    type=str,
    default=2 * 1024 * 1024 * 1024,
)

# Default path — value stays int
args = parser.parse_args([])
# getattr(args, 'neuron.events_retention_size') == 2147483648 (int)  ✓

# CLI path — argparse coerces to str, breaks RotatingFileHandler
args = parser.parse_args(['--neuron.events_retention_size', '1000000000'])
# getattr(args, 'neuron.events_retention_size') == '1000000000' (str)
# Downstream: RotatingFileHandler.shouldRollover does `self.maxBytes > 0`
# TypeError: '>' not supported between instances of 'str' and 'int'

Affected code paths

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions