{"record":{"id":"66b5513fba49aaf5","repo":"HumanSignal/label-studio","slug":"incorrect-value-in-key-key-value-it-sho","errorCode":null,"errorMessage":"Incorrect value in key \"{key}\" = \"{value}\". It should be digit string.","messagePattern":"Incorrect value in key \"(.+?)\" = \"(.+?)\"\\. It should be digit string\\.","errorType":"validation","errorClass":"ValidationError","httpStatus":null,"severity":"error","filePath":"label_studio/core/utils/params.py","lineNumber":51,"sourceCode":"        raise ValidationError({key: str(e)})\n\n\ndef int_from_request(params, key, default):\n    \"\"\"Get integer from request GET, POST, etc\n\n    :param params: dict POST, GET, etc\n    :param key: key to find\n    :param default: default value\n    :return: int\n    \"\"\"\n    value = params.get(key, default)\n\n    # str\n    if isinstance(value, str):\n        try:\n            return int(value)\n        except ValueError:\n            raise ValidationError({key: f'Incorrect value in key \"{key}\" = \"{value}\". It should be digit string.'})\n        except Exception as e:\n            raise ValidationError({key: str(e)})\n    # int\n    elif isinstance(value, int):\n        return value\n    # other\n    else:\n        raise ValidationError(\n            {key: f'Incorrect value type in key \"{key}\" = \"{value}\". It should be digit string or integer.'}\n        )\n\n\ndef float_from_request(params, key, default):\n    \"\"\"Get float from request GET, POST, etc\n\n    :param params: dict POST, GET, etc\n    :param key: key to find\n    :param default: default value","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/HumanSignal/label-studio/blob/0b49e9b53917880baf1dd85d574fe5541a9aafb2/label_studio/core/utils/params.py#L33-L69","documentation":"int_from_request coerces the value of a request parameter keyed by `key` to int. If the value is a string that int() cannot parse (ValueError), it raises DRF ValidationError mapping the key to 'Incorrect value in key ... It should be digit string.' Other unexpected exceptions are also wrapped as ValidationError with the exception text.","triggerScenarios":"Calling int_from_request (directly or via paginator/get/post/get_prepare_params) with a non-numeric string for an integer parameter — e.g. ?page=abc, ?id=1.5, ?project=first, or empty string.","commonSituations":"Users hand-editing paginated API URLs; frontends sending placeholder or NaN-ish values; IDs pasted with extra characters; empty query params (?page=).","solutions":["Send a valid base-10 digit string (e.g. page=2, id=42); the message points at the offending key and value.","On the client, coerce/validate numeric inputs before building the request.","Handle DRF ValidationError (HTTP 400) gracefully and show a friendly message; retry with a corrected value.","Check for empty strings — an empty value also fails int() parsing."],"exampleFix":"// before\nGET /api/tasks/?page=two\n// after\nGET /api/tasks/?page=2","handlingStrategy":"try-catch","validationCode":"def is_digit_string(v) -> bool:\n    return isinstance(v, int) or (isinstance(v, str) and v.isdigit())","typeGuard":null,"tryCatchPattern":"try:\n    page = int_from_request(request.query_params, 'page', 1)\nexcept ValidationError as e:\n    return Response({'error': e.detail, 'hint': 'page must be a digit string'}, status=400)","preventionTips":["Coerce page/id params with int() on the client before building URLs.","Don't hand-edit paginated URLs; use returned next/previous links.","Strip whitespace and disallow empty query values for numeric keys.","Return clear 400s so API consumers can correct inputs."],"tags":["validation","parameters","integer","request"],"backgroundTag":"invalid-integer-parameter","analyzedSha":"0b49e9b53917880baf1dd85d574fe5541a9aafb2","analyzedAt":"2026-08-29T00:39:52.578Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}