xai-org/x-algorithm · error · ValueError

Renew interval must be greater than 0

Error message

Renew interval must be greater than 0

What it means

KerberosConfig.renew_interval controls how often the background renewal loop refreshes the TGT. __init__ rejects values <= 0 because a non-positive interval would spin the loop or disable renewal entirely. It is a straightforward pydantic-era numeric sanity check at construction time.

Source

Thrown at grox/libs/kerberos_cli/kerberos.py:28

class KerberosConfig(BaseModel):
    keytab_path: str
    principal: str
    renew_interval: int = 3600
    attempts: int = 5
    retry_interval: int = 60


class KerberosRenewer:
    def __init__(self, keytab_path: str, principal: str, **kwargs):
        self._renewer: asyncio.Task | None = None
        self.config = KerberosConfig(
            keytab_path=keytab_path, principal=principal, **kwargs
        )
        if not Path(self.config.keytab_path).exists():
            raise FileNotFoundError(f"Keytab file not found: {self.config.keytab_path}")
        if self.config.renew_interval <= 0:
            raise ValueError("Renew interval must be greater than 0")
        if self.config.attempts <= 0:
            raise ValueError("Attempts must be greater than 0")
        if self.config.retry_interval <= 0:
            raise ValueError("Retry interval must be greater than 0")

    async def _kerberos_renewal_loop(self):
        while True:
            attempts = self.config.attempts
            while attempts > 0:
                attempts -= 1
                try:
                    await self._renew_kerberos_ticket()
                    logger.info(
                        f"Kerberos ticket renewed successfully for {self.config.principal}"
                    )
                    break
                except Exception:
                    if attempts == 0:

View on GitHub (pinned to 24c60942c5)

Solutions

  1. Set renew_interval to a positive number of seconds (commonly well under the 24h TGT lifetime, e.g. 3600).
  2. Fix the config source so the omitted field resolves to a sane default instead of 0.

Example fix

# before
client = KerberosClient(kt, principal, renew_interval=0)  # ValueError

# after
client = KerberosClient(kt, principal, renew_interval=3600)
Defensive patterns

Strategy: validation

Validate before calling

renew_interval = renew_interval or 3600
assert renew_interval > 0
client = KerberosClient(kt, principal, renew_interval=renew_interval)

Try / catch

try:
    client = KerberosClient(kt, p, renew_interval=ri)
except ValueError as e:
    if 'Renew interval' in str(e):
        client = KerberosClient(kt, p, renew_interval=3600)
    else:
        raise

Prevention

When it happens

Trigger: KerberosClient(..., renew_interval=0) or a negative value, typically from a config default that was never set or parsed as 0.

Common situations: Config file with renew_interval commented out and a fallback of 0; unit-sourced value where someone confused seconds with milliseconds and set 0 to 'use default'; templating emitting 0 for optional fields.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of xai-org/x-algorithm@24c60942c5 (2026-08-28). Data as JSON: /api/errors/5ea876f16f6690e0. Report an issue: GitHub.