Skip to content

bug(web_fetch): cache TTL resolver logs spurious WARNING on every call when env unset + stale os.environ tests #11246

Closed

Description

@mrveiss

Problems (found via scoped unit-test triage)

web_fetch/cache.py _resolve_web_fetch_cache_ttl() reads config.misc.web_fetch_cache_ttl, a str SSOT field defaulting to "" (ssot_config.py:1562). Two issues:

  1. Runtime bug — spurious warning: the guard is if raw is None, which does not catch the empty-string default. So when AUTOBOT_WEB_FETCH_CACHE_TTL is unset (the common case), the resolver hits int("") → ValueError → logs WARNING AUTOBOT_WEB_FETCH_CACHE_TTL='' is not an integer; falling back to 86400s on every call (and at import). Noise in normal operation.

  2. Stale tests: tests/unit/web_fetch/test_cache.py TestTTLResolver/TestMaxBytesResolver patch os.environ, but the resolvers read config.misc.* (loaded once at import), so the override never takes effect — test_env_override (TTL + MaxBytes) fail even when run in isolation (2 failed, 20 passed); the other cases passed only by accident (config stayed ""/0 → default).

Fix

  • Resolver: treat empty/None as 'use default' without warning (if raw is None or raw == ""); only a non-empty non-integer value warns.
  • Tests: patch config.misc.web_fetch_cache_ttl / config.misc.web_fetch_max_bytes (the actual source) instead of os.environ; reframe the MaxBytes 'invalid string' case (impossible for an int field) to the zero-fallback path.

Acceptance

  • No WARNING when the TTL env var is unset.
  • test_cache.py genuinely exercises the resolvers via config; full file green.

Activity

  1. mrveiss commented on Jul 8, 2026

    @mrveiss
    OwnerAuthor

    Closed — merged to Dev_new_gui (PR #11247). Resolver now treats the empty-string (unset) default as 'use default' silently — no more WARNING on every call; only a non-empty non-integer value warns. Tests patch config.misc.web_fetch_cache_ttl/web_fetch_max_bytes (the real source) instead of os.environ. test_cache.py = 22 passed (was 20 passed / 2 failed). black/isort/compile clean; CI green.

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions