{"record":{"id":"6a6c9f3fa1819e0f","repo":"HumanSignal/label-studio","slug":"user-filter-values-must-be-integer-ids","errorCode":null,"errorMessage":"User filter values must be integer ids.","messagePattern":"User filter values must be integer ids\\.","errorType":"validation","errorClass":"ValidationError","httpStatus":400,"severity":"error","filePath":"label_studio/data_manager/managers.py","lineNumber":661,"sourceCode":"        return []\n    if (\n        isinstance(value, list)\n        and not isinstance(value, ResolvedUserFilterIds)\n        and len(value) > settings.DATA_MANAGER_LIST_FILTER_MAX_VALUES\n    ):\n        raise ValidationError(\n            f'User filter list exceeds maximum size of {settings.DATA_MANAGER_LIST_FILTER_MAX_VALUES}.'\n        )\n    raw = value if isinstance(value, list) else [value]\n    ids = []\n    seen = set()\n    for item in raw:\n        try:\n            if isinstance(item, bool) or (isinstance(item, float) and not item.is_integer()):\n                raise ValueError\n            user_id = int(item)\n        except (TypeError, ValueError):\n            raise ValidationError('User filter values must be integer ids.') from None\n        if user_id not in seen:\n            seen.add(user_id)\n            ids.append(user_id)\n    return ids\n\n\ndef _annotation_id(value):\n    \"\"\"Return an exact integer ID, accepting integer-valued Number representations only.\"\"\"\n    if isinstance(value, bool):\n        return None\n    if isinstance(value, int):\n        return value\n    try:\n        number = Decimal(str(value).strip())\n    except (AttributeError, InvalidOperation, ValueError):\n        return None\n    if not number.is_finite() or number != number.to_integral_value():\n        return None","sourceCodeStart":643,"sourceCodeEnd":679,"githubUrl":"https://github.com/HumanSignal/label-studio/blob/0b49e9b53917880baf1dd85d574fe5541a9aafb2/label_studio/data_manager/managers.py#L643-L679","documentation":"parse_user_filter_ids converts filter values into a deduplicated list of integer ids. Booleans, non-integer floats, and anything not coercible with int() raise ValidationError('User filter values must be integer ids.') — the parser is deliberately strict to keep ids clean.","triggerScenarios":"Values like '12abc', 1.5, true, null, or nested objects inside the filter's list/scalar value passed to add_user_filter or validate().","commonSituations":"JavaScript sending string ids with whitespace/symbols; spreadsheet exports yielding float ids (1.0 is OK, 1.5 is not); booleans leaking in from checkboxes; NaN/undefined serialized as strings.","solutions":["Coerce each entry with int(str) or Number.parseInt and validate before sending","Filter out booleans/null/undefined client-side","Ensure ids originate from the API's numeric id fields, not labels or UUIDs","Sanitize CSV/spreadsheet imports to numeric values"],"exampleFix":"// before\nfilter_value = [\"1\", true, 2.5]\n// after\nfilter_value = [int(x) for x in raw if str(x).strip().lstrip('-').isdigit()]  # -> [1, 2]","handlingStrategy":"validation","validationCode":"function toIdList(raw) {\n  return raw.filter(x => typeof x !== 'boolean' && x !== null && x !== undefined)\n            .map(x => Number(x))\n            .filter(n => Number.isInteger(n) && !Number.isNaN(n));\n}","typeGuard":"const isId = (x) => (typeof x === 'number' && Number.isInteger(x)) || (typeof x === 'string' && /^-?\\d+$/.test(x.trim()));","tryCatchPattern":"try:\n    add_user_filter(...)\nexcept ValidationError as e:\n    if 'must be integer ids' in str(e): sanitize_ids_and_retry(e)\n    else: raise","preventionTips":["Source ids only from numeric API fields, never labels or display text","Strip whitespace and parse with Number.parseInt on the client","Exclude booleans/null from checkbox-driven selections","Sanitize spreadsheet/CSV values to integers at import"],"tags":["validation","filters","type-error","integer-parsing"],"backgroundTag":"invalid-integer-id","analyzedSha":"0b49e9b53917880baf1dd85d574fe5541a9aafb2","analyzedAt":"2026-08-29T00:39:52.578Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}