{"record":{"id":"bc203920a9f2f9c3","repo":"xai-org/x-algorithm","slug":"attempts-must-be-greater-than-0","errorCode":null,"errorMessage":"Attempts must be greater than 0","messagePattern":"Attempts must be greater than 0","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"grox/libs/kerberos_cli/kerberos.py","lineNumber":30,"sourceCode":"    keytab_path: str\n    principal: str\n    renew_interval: int = 3600\n    attempts: int = 5\n    retry_interval: int = 60\n\n\nclass KerberosRenewer:\n    def __init__(self, keytab_path: str, principal: str, **kwargs):\n        self._renewer: asyncio.Task | None = None\n        self.config = KerberosConfig(\n            keytab_path=keytab_path, principal=principal, **kwargs\n        )\n        if not Path(self.config.keytab_path).exists():\n            raise FileNotFoundError(f\"Keytab file not found: {self.config.keytab_path}\")\n        if self.config.renew_interval <= 0:\n            raise ValueError(\"Renew interval must be greater than 0\")\n        if self.config.attempts <= 0:\n            raise ValueError(\"Attempts must be greater than 0\")\n        if self.config.retry_interval <= 0:\n            raise ValueError(\"Retry interval must be greater than 0\")\n\n    async def _kerberos_renewal_loop(self):\n        while True:\n            attempts = self.config.attempts\n            while attempts > 0:\n                attempts -= 1\n                try:\n                    await self._renew_kerberos_ticket()\n                    logger.info(\n                        f\"Kerberos ticket renewed successfully for {self.config.principal}\"\n                    )\n                    break\n                except Exception:\n                    if attempts == 0:\n                        logger.error(\n                            f\"Kerberos renewal failed after {self.config.attempts} attempts: {traceback.format_exc()}\"","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/xai-org/x-algorithm/blob/24c60942c5c5fdad3a6addffb4c6e6d2f228f04f/grox/libs/kerberos_cli/kerberos.py#L12-L48","documentation":"attempts sets how many times the renewal loop retries a failed kinit before backing off. __init__ requires attempts > 0; zero or negative values would mean a failed renewal is never retried, silently losing the ticket. Raised at construction.","triggerScenarios":"KerberosClient(..., attempts=0) or negative, e.g. from a config where attempts was meant to be 'infinite' and someone used 0.","commonSituations":"Config refactor that dropped the attempts key and defaulted it to 0; environment-specific override files with attempts: 0 to 'disable retries' — not supported here.","solutions":["Set attempts to a positive integer (e.g. 3–5 retries before the retry_interval wait).","If you wanted unlimited retries, keep attempts positive and rely on the outer while True loop which resets attempts each cycle."],"exampleFix":"# before\nclient = KerberosClient(kt, principal, attempts=0)  # ValueError\n\n# after\nclient = KerberosClient(kt, principal, attempts=3)","handlingStrategy":"validation","validationCode":"attempts = attempts if attempts and attempts > 0 else 3\nclient = KerberosClient(kt, principal, attempts=attempts)","typeGuard":null,"tryCatchPattern":"try:\n    client = KerberosClient(kt, p, attempts=a)\nexcept ValueError as e:\n    if 'Attempts' in str(e):\n        client = KerberosClient(kt, p, attempts=3)\n    else:\n        raise","preventionTips":["Treat 0 as invalid for retry counts in config parsing","Centralize Kerberos config defaults in one settings class"],"tags":["kerberos","config-validation","retries"],"backgroundTag":"invalid-config-value","analyzedSha":"24c60942c5c5fdad3a6addffb4c6e6d2f228f04f","analyzedAt":"2026-08-28T11:40:14.686Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}