{"record":{"id":"e4597a0552f3988b","repo":"CoplayDev/unity-mcp","slug":"context-dict-values-must-be-numeric-got-value","errorCode":null,"errorMessage":"{context} dict values must be numeric, got {value}","messagePattern":"(.+?) dict values must be numeric, got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"Server/src/cli/commands/texture.py","lineNumber":126,"sourceCode":"    if isinstance(value, str):\n        if value.startswith(\"#\"):\n            return _parse_hex_color(value)\n        value = try_parse_json(value, context)\n\n    # Handle dict with r/g/b keys (e.g., {\"r\": 1, \"g\": 0, \"b\": 0} or {\"r\": 1, \"g\": 0, \"b\": 0, \"a\": 1})\n    if isinstance(value, dict):\n        if all(k in value for k in (\"r\", \"g\", \"b\")):\n            try:\n                color = [value[\"r\"], value[\"g\"], value[\"b\"]]\n                if \"a\" in value:\n                    color.append(value[\"a\"])\n                else:\n                    color.append(1.0 if _is_normalized_color(color) else 255)\n                if _is_normalized_color(color):\n                    return [int(round(float(c) * 255)) for c in color]\n                return [int(c) for c in color]\n            except (TypeError, ValueError):\n                raise ValueError(f\"{context} dict values must be numeric, got {value}\")\n        raise ValueError(f\"{context} dict must have 'r', 'g', 'b' keys, got {list(value.keys())}\")\n\n    if isinstance(value, (list, tuple)):\n        if len(value) == 3:\n            value = list(value) + [1.0 if _is_normalized_color(value) else 255]\n        if len(value) == 4:\n            try:\n                if _is_normalized_color(value):\n                    return [int(round(float(c) * 255)) for c in value]\n                return [int(c) for c in value]\n            except (TypeError, ValueError):\n                raise ValueError(\n                    f\"{context} values must be numeric, got {value}\")\n        raise ValueError(\n            f\"{context} must have 3 or 4 components, got {len(value)}\")\n\n    raise ValueError(f\"{context} must be a list or hex string\")\n","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/CoplayDev/unity-mcp/blob/c21bf496bca87d54e75bad048563c3adb1782081/Server/src/cli/commands/texture.py#L108-L144","documentation":"Raised by _normalize_color (texture.py:126) when the value is a dict containing r/g/b keys but one or more of its values cannot be converted to a float (TypeError or ValueError during the numeric conversion). The 'context' label names the offending field (e.g. 'set-pixels color dict values must be numeric...'). This is the dict branch of color normalization; a correctly-keyed dict with non-numeric values triggers it.","triggerScenarios":"Passing a color dict like {\"r\": \"red\", \"g\": 0, \"b\": 0} or {\"r\": null, \"g\": 1, \"b\": 1} via --color, --palette, a pixels array, or set-pixels color. Any r/g/b(/a) value that float() cannot parse hits this.","commonSituations":"Pasting a Unity color object that uses string color names; mixing types (a string in one channel); a value of null in a channel; a dict produced by JSON where numbers were quoted.","solutions":["Make every r/g/b(/a) value a number (int or float) in 0-255 or normalized 0-1 form.","Remove quotes around numeric values in the JSON dict.","Replace null channel values with an explicit number (e.g. alpha 255 or 1.0)."],"exampleFix":"# before\nunity-mcp texture create Assets/Tex.png --color '{\"r\":\"red\",\"g\":0,\"b\":0}'\n\n# after\nunity-mcp texture create Assets/Tex.png --color '{\"r\":255,\"g\":0,\"b\":0}'","handlingStrategy":"type-guard","validationCode":"# Python - before normalizing a dict color\nif isinstance(value, dict):\n    for k in (\"r\", \"g\", \"b\"):\n        if not isinstance(value.get(k), (int, float)) or isinstance(value.get(k), bool):\n            raise ValueError(f\"{context} dict values must be numeric, got {value}\")","typeGuard":"def is_numeric_color_dict(v) -> bool:\n    return isinstance(v, dict) and all(k in v for k in (\"r\",\"g\",\"b\")) and all(isinstance(v[k],(int,float)) and not isinstance(v[k],bool) for k in (\"r\",\"g\",\"b\"))","tryCatchPattern":"try:\n    color = _normalize_color(value, context)\nexcept ValueError as e:\n    print_error(str(e)); sys.exit(1)","preventionTips":["Keep r/g/b(/a) values as unquoted numbers.","Replace null channels with explicit 0-255 or 0-1 values."],"tags":["python","cli","texture","color","validation","value-error"],"backgroundTag":null,"analyzedSha":"c21bf496bca87d54e75bad048563c3adb1782081","analyzedAt":"2026-08-13T17:36:56.095Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}