{"record":{"id":"635f9eb5d843027f","repo":"redis/redis-py","slug":"both-ignore-max-time-diff-and-ignore-max-val-diff","errorCode":null,"errorMessage":"Both ignore_max_time_diff and ignore_max_val_diff must be set.","messagePattern":"Both ignore_max_time_diff and ignore_max_val_diff must be set\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"redis/commands/timeseries/commands.py","lineNumber":2137,"sourceCode":"        \"\"\"Append EMPTY property to params.\"\"\"\n        if empty:\n            params.append(\"EMPTY\")\n\n    @staticmethod\n    def _append_exclude_empty(params: list[EncodableT], exclude_empty: bool | None):\n        \"\"\"Append EXCLUDEEMPTY property to params.\"\"\"\n        if exclude_empty:\n            params.append(\"EXCLUDEEMPTY\")\n\n    @staticmethod\n    def _append_insertion_filters(\n        params: list[EncodableT],\n        ignore_max_time_diff: int | None = None,\n        ignore_max_val_diff: Number | None = None,\n    ):\n        \"\"\"Append insertion filters to params.\"\"\"\n        if (ignore_max_time_diff is None) != (ignore_max_val_diff is None):\n            raise ValueError(\n                \"Both ignore_max_time_diff and ignore_max_val_diff must be set.\"\n            )\n\n        if ignore_max_time_diff is not None and ignore_max_val_diff is not None:\n            params.extend(\n                [\"IGNORE\", str(ignore_max_time_diff), str(ignore_max_val_diff)]\n            )\n","sourceCodeStart":2119,"sourceCodeEnd":2145,"githubUrl":"https://github.com/redis/redis-py/blob/6a6b581b48225afa0b76912d1028c6035baee932/redis/commands/timeseries/commands.py#L2119-L2145","documentation":"Raised by _append_insertion_filters when exactly one of ignore_max_time_diff / ignore_max_val_diff is provided. The TS.IGNORE clause requires both a max time difference and a max value difference; setting only one is a caller bug. Note this is a ValueError, not a DataError.","triggerScenarios":"Calling a TS.ADD-style insert with ignore_max_time_diff=1000 but ignore_max_val_diff unset, or vice-versa.","commonSituations":"Config that exposes only one of the two IGNORE knobs. Copying a partial example. Renaming one parameter during a refactor.","solutions":["Set both ignore_max_time_diff and ignore_max_val_diff together.","Omit both if you do not want insertion filtering.","Pair them in a single config object so they are always supplied together."],"exampleFix":"// before\nclient.ts().add(key, ts, value,\n    ignore_max_time_diff=1000)  # missing val diff\n// after\nclient.ts().add(key, ts, value,\n    ignore_max_time_diff=1000, ignore_max_val_diff=5.0)","handlingStrategy":"validation","validationCode":"if (ignore_max_time_diff is None) != (ignore_max_val_diff is None):\n    raise ValueError('set both ignore_* or neither')\nclient.ts().add(key, ts, value,\n    ignore_max_time_diff=ignore_max_time_diff,\n    ignore_max_val_diff=ignore_max_val_diff)","typeGuard":null,"tryCatchPattern":"try:\n    client.ts().add(key, ts, value,\n        ignore_max_time_diff=td, ignore_max_val_diff=vd)\nexcept ValueError:\n    client.ts().add(key, ts, value)","preventionTips":["Pair the two IGNORE parameters in a single config object.","Supply both or neither."],"tags":["redistimeseries","add","ignore","argument-validation"],"backgroundTag":null,"analyzedSha":"6a6b581b48225afa0b76912d1028c6035baee932","analyzedAt":"2026-08-10T12:52:44.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}