{"record":{"id":"633db601309411b2","repo":"CoplayDev/unity-mcp","slug":"context-must-have-3-or-4-components-got-len-va","errorCode":null,"errorMessage":"{context} must have 3 or 4 components, got {len(value)}","messagePattern":"(.+?) must have 3 or 4 components, got (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"Server/src/cli/commands/texture.py","lineNumber":140,"sourceCode":"                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:\n    if value is None:\n        raise ValueError(f\"{context} is required\")","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/CoplayDev/unity-mcp/blob/c21bf496bca87d54e75bad048563c3adb1782081/Server/src/cli/commands/texture.py#L122-L158","documentation":"Raised by _normalize_color (texture.py:140) when the value is a list/tuple whose length is neither 3 nor 4. Colors must be RGB (3) or RGBA (4) component arrays. The 'context' label names the field (e.g. 'color must have 3 or 4 components, got 2').","triggerScenarios":"Passing --color '[255,0]' (2 elements), '[255,0,0,0,0]' (5), or a single-element list. Applies to --color, palette items, pixel entries, and set-pixels color when given as a list.","commonSituations":"Typing an incomplete color (forgot a channel); passing a 2D point or pivot array into a color argument; a palette generator emitting pairs instead of triples.","solutions":["Provide exactly 3 ([r,g,b]) or 4 ([r,g,b,a]) numeric components.","If you omitted alpha, switch to the 3-element form (alpha defaults to 255 or 1.0).","Double-check the array length before passing it as a color."],"exampleFix":"# before\nunity-mcp texture create Assets/Tex.png --color '[255,0]'\n\n# after\nunity-mcp texture create Assets/Tex.png --color '[255,0,0]'","handlingStrategy":"validation","validationCode":"# Python - check length before _normalize_color\nif isinstance(value, (list, tuple)) and len(value) not in (3, 4):\n    raise ValueError(f\"{context} must have 3 or 4 components, got {len(value)}\")","typeGuard":"def is_valid_color_length(v) -> bool: return isinstance(v,(list,tuple)) and len(v) in (3,4)","tryCatchPattern":"try:\n    color = _normalize_color(value, context)\nexcept ValueError as e:\n    print_error(str(e)); sys.exit(1)","preventionTips":["Use exactly 3 (RGB) or 4 (RGBA) components.","Prefer the 3-component form when alpha is not needed."],"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"}