{"record":{"id":"551761017d40cefa","repo":"redis/redis-py","slug":"frequency-must-be-an-integer","errorCode":null,"errorMessage":"frequency must be an integer","messagePattern":"frequency must be an integer","errorType":"validation","errorClass":"DataError","httpStatus":null,"severity":"error","filePath":"redis/commands/core.py","lineNumber":4287,"sourceCode":"        \"\"\"\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 = ...,\n        xx: bool = ...,\n        keepttl: bool = ...,\n        get: bool = ...,\n        exat: AbsExpiryT | None = ...,\n        pxat: AbsExpiryT | None = ...,\n        ifeq: bytes | str | None = ...,\n        ifne: bytes | str | None = ...,","sourceCodeStart":4269,"sourceCodeEnd":4305,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/commands/core.py#L4269-L4305","documentation":"Raised as a `DataError` by `restore()` (redis/commands/core.py:4286) when `int(frequency)` raises `ValueError`, i.e. `frequency` is provided but is not integer-coercible. RESTORE's FREQ eviction counter must be an integer.","triggerScenarios":"`r.restore('k', 0, blob, frequency='high')`, `r.restore('k', 0, blob, frequency='2.7')`, or any non-int value for frequency.","commonSituations":"Deserialized frequency values typed as strings; passing a labeled/enum frequency instead of its numeric counter; user input not sanitized.","solutions":["Pass an integer for `frequency`.","Validate/coerce before calling: `frequency = int(frequency)`.","Guard against None — frequency is optional and should be omitted, not passed as a string, when unused."],"exampleFix":"// before\nr.restore('k', 0, blob, frequency='5')\n// after\nr.restore('k', 0, blob, frequency=int('5'))","handlingStrategy":"type-guard","validationCode":"if frequency is not None:\n    frequency = int(frequency)\nr.restore('k', 0, blob, frequency=frequency)","typeGuard":"def is_intlike(v) -> bool:\n    try:\n        int(v)\n        return True\n    except (TypeError, ValueError):\n        return False","tryCatchPattern":null,"preventionTips":["Coerce frequency to int before calling.","Omit frequency entirely (None) when unused."],"tags":["restore","arguments","validation","dataerror"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}