{"record":{"id":"88f70ddc884eaacd","repo":"CoplayDev/unity-mcp","slug":"set-pixels-requires-color-or-pixels","errorCode":null,"errorMessage":"set-pixels requires 'color' or 'pixels'","messagePattern":"set-pixels requires 'color' or 'pixels'","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"Server/src/cli/commands/texture.py","lineNumber":205,"sourceCode":"        width = value.get(\"width\")\n        height = value.get(\"height\")\n        if width is None or height is None:\n            raise ValueError(\n                \"set-pixels requires width and height when pixels are provided\")\n        width = int(width)\n        height = int(height)\n        if width <= 0 or height <= 0:\n            raise ValueError(\"set-pixels width and height must be positive\")\n        result[\"width\"] = width\n        result[\"height\"] = height\n        result[\"pixels\"] = _normalize_pixels(\n            value[\"pixels\"], width, height, \"set-pixels pixels\")\n\n    if \"color\" in value:\n        result[\"color\"] = _normalize_color(value[\"color\"], \"set-pixels color\")\n\n    if \"pixels\" not in value and \"color\" not in value:\n        raise ValueError(\"set-pixels requires 'color' or 'pixels'\")\n\n    if \"x\" in value:\n        result[\"x\"] = int(value[\"x\"])\n    if \"y\" in value:\n        result[\"y\"] = int(value[\"y\"])\n\n    if \"width\" in value and \"pixels\" not in value:\n        result[\"width\"] = int(value[\"width\"])\n    if \"height\" in value and \"pixels\" not in value:\n        result[\"height\"] = int(value[\"height\"])\n\n    return result\n\n\ndef _map_enum(value: Any, mapping: dict[str, str]) -> Any:\n    if isinstance(value, str):\n        key = value.lower()\n        return mapping.get(key, value)","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/CoplayDev/unity-mcp/blob/c21bf496bca87d54e75bad048563c3adb1782081/Server/src/cli/commands/texture.py#L187-L223","documentation":"Thrown by _normalize_set_pixels() when the object contains neither 'pixels' nor 'color'. The set-pixels operation must write something to the texture, so at least one of these content keys is mandatory; an object with only metadata (width, height, x, y) is rejected.","triggerScenarios":"Passing `--set-pixels '{\"width\":2,\"height\":2,\"x\":0,\"y\":0}'` with no pixels or color. Providing an empty object, or only coordinate/dimension keys.","commonSituations":"A developer supplies dimensions and offsets expecting a clear operation, not realizing set-pixels requires explicit content. Or a templating bug omits the content key.","solutions":["Add a color key: `--set-pixels '{\"color\":\"#FF0000\",\"width\":2,\"height\":2}'`.","Or add a pixels array with matching dimensions.","If you intended a no-op, omit the --set-pixels option entirely rather than passing an empty object."],"exampleFix":"// before\n--set-pixels '{\"width\":2,\"height\":2,\"x\":0,\"y\":0}'\n// after\n--set-pixels '{\"color\":\"#FF0000\",\"width\":2,\"height\":2,\"x\":0,\"y\":0}'","handlingStrategy":"validation","validationCode":"if \"pixels\" not in sp and \"color\" not in sp:\n    raise ValueError(\"set-pixels requires 'color' or 'pixels'\")","typeGuard":"def has_content_key(v: dict) -> bool:\n    return \"color\" in v or \"pixels\" in v","tryCatchPattern":"try:\n    payload = _normalize_set_pixels(sp)\nexcept ValueError as e:\n    print_error(str(e)); sys.exit(1)","preventionTips":["Always include a color or pixels key.","Omit --set-pixels entirely for a no-op rather than an empty object."],"tags":["cli","validation","texture","input-validation"],"backgroundTag":null,"analyzedSha":"c21bf496bca87d54e75bad048563c3adb1782081","analyzedAt":"2026-08-13T17:36:56.095Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}