{"record":{"id":"3ff3789b1932a210","repo":"CoplayDev/unity-mcp","slug":"context-values-must-be-numeric-got-value","errorCode":null,"errorMessage":"{context} values must be numeric, got {value}","messagePattern":"(.+?) values must be numeric, got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"Server/src/cli/commands/texture.py","lineNumber":138,"sourceCode":"                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\n\ndef _normalize_palette(value: Any, context: str) -> list[list[int]]:\n    if value is None:\n        return []\n    if isinstance(value, str):\n        value = try_parse_json(value, context)\n    if not isinstance(value, list):\n        raise ValueError(f\"{context} must be a list of colors\")\n    return [_normalize_color(color, f\"{context} item\") for color in value]\n\n\ndef _normalize_pixels(value: Any, width: int, height: int, context: str) -> list[list[int]] | str:","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/CoplayDev/unity-mcp/blob/c21bf496bca87d54e75bad048563c3adb1782081/Server/src/cli/commands/texture.py#L120-L156","documentation":"Raised by _normalize_color (texture.py:138) when the value is a list/tuple of 4 components (or 3 extended to 4) but a component cannot be converted via float()/int() (TypeError or ValueError). The 'context' labels the field (e.g. 'color values must be numeric...'). This is the list/tuple branch; correct length but non-numeric contents triggers it.","triggerScenarios":"Passing --color '[\"red\",0,0]' or --color '[255,0,null]' or a 4-element array with a string/null in any slot. Same for palette items, pixels, and set-pixels color supplied as a list.","commonSituations":"A JSON array where one channel was quoted or left null; mixing a color name string into an otherwise numeric list; copy-pasting partial data.","solutions":["Ensure every list element is a number (0-255 or normalized 0-1).","Unquote numeric elements and replace nulls with explicit numbers.","Validate the array contains only int/float before passing."],"exampleFix":"# before\nunity-mcp texture create Assets/Tex.png --color '[\"red\",0,0,255]'\n\n# after\nunity-mcp texture create Assets/Tex.png --color '[255,0,0,255]'","handlingStrategy":"type-guard","validationCode":"# Python - before normalizing a list color\nif isinstance(value, (list, tuple)):\n    if not all(isinstance(c, (int, float)) and not isinstance(c, bool) for c in value):\n        raise ValueError(f\"{context} values must be numeric, got {value}\")","typeGuard":"def is_numeric_color_list(v) -> bool:\n    return isinstance(v, (list, tuple)) and all(isinstance(c, (int, float)) and not isinstance(c, bool) for c in v)","tryCatchPattern":"try:\n    color = _normalize_color(value, context)\nexcept ValueError as e:\n    print_error(str(e)); sys.exit(1)","preventionTips":["Ensure list elements are numbers, not strings or null.","Validate the array contents before passing."],"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"}