{"record":{"id":"6a0acebd0357766f","repo":"CoplayDev/unity-mcp","slug":"context-must-be-a-list-of-colors","errorCode":null,"errorMessage":"{context} must be a list of colors","messagePattern":"(.+?) must be a list of colors","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"Server/src/cli/commands/texture.py","lineNumber":152,"sourceCode":"                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:\n    if value is None:\n        raise ValueError(f\"{context} is required\")\n    if isinstance(value, str):\n        if value.startswith(\"base64:\"):\n            return value\n        trimmed = value.strip()\n        if trimmed.startswith(\"[\") and trimmed.endswith(\"]\"):\n            value = try_parse_json(trimmed, context)\n        else:\n            return f\"base64:{value}\"\n    if isinstance(value, list):\n        expected_count = width * height\n        if len(value) != expected_count:\n            raise ValueError(","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/CoplayDev/unity-mcp/blob/c21bf496bca87d54e75bad048563c3adb1782081/Server/src/cli/commands/texture.py#L134-L170","documentation":"Raised by _normalize_palette (texture.py:152) when the palette value, after optional JSON parsing, is not a list. A palette must be a JSON array of colors. The 'context' label is 'palette' (from the create command's --palette option).","triggerScenarios":"Passing --palette '\"#FF0000\"' (a single color string, not an array), --palette '{\"a\":1}' (a dict), or a JSON string that parses to a scalar. The create command calls _normalize_palette(palette, 'palette').","commonSituations":"Forgetting the outer array brackets around palette colors; passing a single color where a list is required; a JSON object where an array was intended.","solutions":["Pass the palette as a JSON array of colors, e.g. '[\"#FF0000\",\"#00FF00\"]'.","Wrap a single color in brackets: '[\"#FF0000\"]'.","Confirm the --palette JSON parses to a list before running."],"exampleFix":"# before\nunity-mcp texture create Assets/Tex.png --pattern checkerboard --palette '\"#FF0000\"'\n\n# after\nunity-mcp texture create Assets/Tex.png --pattern checkerboard --palette '[\"#FF0000\",\"#00FF00\"]'","handlingStrategy":"type-guard","validationCode":"# Python - ensure palette is a list before _normalize_palette\nif not isinstance(value, list):\n    raise ValueError(f\"{context} must be a list of colors\")","typeGuard":"def is_palette_list(v) -> bool: return isinstance(v, list)","tryCatchPattern":"try:\n    palette = _normalize_palette(value, context)\nexcept ValueError as e:\n    print_error(str(e)); sys.exit(1)","preventionTips":["Always wrap palette colors in a JSON array.","Pass a single color as [color], not color."],"tags":["python","cli","texture","palette","validation","value-error"],"backgroundTag":null,"analyzedSha":"c21bf496bca87d54e75bad048563c3adb1782081","analyzedAt":"2026-08-13T17:36:56.095Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}