{"record":{"id":"c686c004ed127471","repo":"HumanSignal/label-studio","slug":"incorrect-value-type-in-key-key-value-i-c686c0","errorCode":null,"errorMessage":"Incorrect value type in key \"{key}\" = \"{value}\". It should be digit string or float.","messagePattern":"Incorrect value type in key \"(.+?)\" = \"(.+?)\"\\. It should be digit string or float\\.","errorType":"validation","errorClass":"ValidationError","httpStatus":null,"severity":"error","filePath":"label_studio/core/utils/params.py","lineNumber":85,"sourceCode":"    :param params: dict POST, GET, etc\n    :param key: key to find\n    :param default: default value\n    :return: float\n    \"\"\"\n    value = params.get(key, default)\n\n    # str\n    if isinstance(value, str):\n        try:\n            return float(value)\n        except ValueError:\n            raise ValidationError({key: f'Incorrect value in key \"{key}\" = \"{value}\". It should be digit string.'})\n    # float\n    elif isinstance(value, float) or isinstance(value, int):\n        return float(value)\n    # other\n    else:\n        raise ValidationError(\n            {key: f'Incorrect value type in key \"{key}\" = \"{value}\". It should be digit string or float.'}\n        )\n\n\ndef list_of_strings_from_request(params, key, default):\n    \"\"\"Get list of strings 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: float\n    \"\"\"\n    value = params.get(key, default)\n    if value is None:\n        return\n    splitters = (',', ';', '|')\n    # str\n    if isinstance(value, str):","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/HumanSignal/label-studio/blob/0b49e9b53917880baf1dd85d574fe5541a9aafb2/label_studio/core/utils/params.py#L67-L103","documentation":"float_from_request raises this when the value is neither a string, float, nor int — i.e. an unsupported type like list, dict, or bool. It signals a type mismatch rather than a parse failure, distinct from error 11 which fires on unparseable strings.","triggerScenarios":"Calling an endpoint that uses float_from_request with a param that Django deserialized into a list (repeated query keys like `?x=1&x=2`), a dict (JSON body nested object), or another non-scalar type.","commonSituations":"Frontends sending arrays via repeated query params; JSON bodies passing nested objects where a scalar number is expected; accidentally passing bool values from typed clients.","solutions":["Send the value once as a single scalar (string or number) instead of repeated/array form.","Client-side: ensure the param is a str/int/float, e.g. str(float(x)) before sending.","Check for accidental JSON nesting of the key in the request body.","Catch ValidationError in the endpoint and return a 400 identifying the key."],"exampleFix":"// before\nGET /api/annotations?score=0.5&score=0.6  (parsed as list)\n\n// after\nGET /api/annotations?score=0.5","handlingStrategy":"validation","validationCode":"def ensure_scalar_number(params, key):\n    value = params.get(key)\n    if isinstance(value, list):\n        value = value[0] if len(value) == 1 else None\n    if not isinstance(value, (str, int, float)):\n        raise ValueError(f'{key} must be a scalar number')\n    return float(value)","typeGuard":"def is_scalar_number(value) -> bool:\n    return isinstance(value, (str, int, float))","tryCatchPattern":"try:\n    score = float_from_request(request.GET, 'score', 0.0)\nexcept ValidationError as e:\n    return Response({'detail': 'score must be a single scalar value'}, status=400)","preventionTips":["Avoid repeated query keys for single-value params","Flatten JSON bodies before sending scalar-typed keys","Map bools to numbers explicitly if numbers are expected"],"tags":["request-validation","django","parameter-type","validation"],"backgroundTag":"invalid-request-parameter-type","analyzedSha":"0b49e9b53917880baf1dd85d574fe5541a9aafb2","analyzedAt":"2026-08-29T00:39:52.578Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}