{"record":{"id":"ca033ae6cf69f45e","repo":"redis/redis-py","slug":"idletimemust-be-an-integer","errorCode":null,"errorMessage":"idletimemust be an integer","messagePattern":"idletimemust be an integer","errorType":"validation","errorClass":"DataError","httpStatus":null,"severity":"error","filePath":"redis/commands/core.py","lineNumber":4280,"sourceCode":"        ``idletime`` Used for eviction, this is the number of seconds the\n        key must be idle, prior to execution.\n\n        ``frequency`` Used for eviction, this is the frequency counter of\n        the object stored at the key, prior to execution.\n\n        For more information, see https://redis.io/commands/restore\n        \"\"\"\n        params = [name, ttl, value]\n        if replace:\n            params.append(\"REPLACE\")\n        if absttl:\n            params.append(\"ABSTTL\")\n        if idletime is not None:\n            params.append(\"IDLETIME\")\n            try:\n                params.append(int(idletime))\n            except ValueError:\n                raise DataError(\"idletimemust be an integer\")\n\n        if frequency is not None:\n            params.append(\"FREQ\")\n            try:\n                params.append(int(frequency))\n            except ValueError:\n                raise DataError(\"frequency must be an integer\")\n\n        return self.execute_command(\"RESTORE\", *params)\n\n    @overload\n    def set(\n        self: SyncClientProtocol,\n        name: KeyT,\n        value: EncodableT,\n        ex: ExpiryT | None = ...,\n        px: ExpiryT | None = ...,\n        nx: bool = ...,","sourceCodeStart":4262,"sourceCodeEnd":4298,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/commands/core.py#L4262-L4298","documentation":"Raised as a `DataError` by `restore()` (redis/commands/core.py:4280) when `int(idletime)` raises `ValueError`, i.e. `idletime` is provided but cannot be parsed as an integer. (Note the literal message has a typo: 'idletimemust be an integer' with no space.) RESTORE's IDLETIME eviction hint must be an integer number of seconds.","triggerScenarios":"`r.restore('k', 0, blob, idletime='abc')`, `r.restore('k', 0, blob, idletime=1.5)` (float string that int() rejects is fine for '1.5'? int('1.5') raises ValueError), or any non-int-coercible value.","commonSituations":"Passing a float (1.5) which `int()` accepts as 1 but a float *string* ('1.5') which it rejects; user/JSON input typed as string; copying a frequency-style string into idletime.","solutions":["Pass an integer for `idletime`.","Coerce and validate before calling: `idletime = int(idletime)`.","If the source is a float string, parse with `float()` then `int()`."],"exampleFix":"// before\nr.restore('k', 0, blob, idletime='1.5')\n// after\nr.restore('k', 0, blob, idletime=int(float('1.5')))","handlingStrategy":"type-guard","validationCode":"if idletime is not None:\n    idletime = int(idletime)  # raises ValueError early if non-integer\nr.restore('k', 0, blob, idletime=idletime)","typeGuard":"def is_intlike(v) -> bool:\n    try:\n        int(v)\n        return True\n    except (TypeError, ValueError):\n        return False","tryCatchPattern":null,"preventionTips":["Sanitize idletime to int at the boundary.","Note the library message has a typo ('idletimemust'); match on DataError type, not substring, in tests."],"tags":["restore","arguments","validation","dataerror","typo"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}