{"record":{"id":"4cb2a72ff57bb2d6","repo":"CoplayDev/unity-mcp","slug":"set-pixels-is-required","errorCode":null,"errorMessage":"set-pixels is required","messagePattern":"set-pixels is required","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"Server/src/cli/commands/texture.py","lineNumber":178,"sourceCode":"        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(\n                f\"{context} must have {expected_count} entries, got {len(value)}\")\n        return [_normalize_color(pixel, f\"{context} pixel\") for pixel in value]\n    raise ValueError(f\"{context} must be a list or base64 string\")\n\n\ndef _normalize_set_pixels(value: Any) -> dict[str, Any]:\n    if value is None:\n        raise ValueError(\"set-pixels is required\")\n    if isinstance(value, str):\n        value = try_parse_json(value, \"set-pixels\")\n    if not isinstance(value, dict):\n        raise ValueError(\"set-pixels must be a JSON object\")\n\n    result: dict[str, Any] = dict(value)\n\n    if \"pixels\" in value:\n        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","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/CoplayDev/unity-mcp/blob/c21bf496bca87d54e75bad048563c3adb1782081/Server/src/cli/commands/texture.py#L160-L196","documentation":"Thrown by _normalize_set_pixels() in the texture CLI when the set-pixels option is omitted entirely (value is None). It is the first guard in the normalizer and signals that the caller invoked a set-pixels-based texture command without supplying the payload the command requires. The error is a pure input-validation failure, not a network or Unity-side problem.","triggerScenarios":"Running a CLI/programmatic call that routes through _normalize_set_pixels with the set-pixels argument unset, e.g. `unity-mcp texture set-pixels <path>` with no --set-pixels option, or calling the normalizer directly with None. Any code path that constructs the params dict but omits the set-pixels key.","commonSituations":"A developer forgets the --set-pixels flag, or a script building the texture command conditionally assigns the option and the condition is false, leaving it None. Common when copy-pasting an example command and trimming arguments.","solutions":["Supply the set-pixels payload: `--set-pixels '{\"color\":\"#FF0000\",\"width\":2,\"height\":2}'`.","If calling the normalizer programmatically, ensure the value argument is a dict (or a JSON string), never None.","Check the texture subcommand help (`unity-mcp texture set-pixels --help`) to confirm the required option name and JSON shape."],"exampleFix":"// before\nunity-mcp texture set-pixels Assets/Tex.png\n// after\nunity-mcp texture set-pixels Assets/Tex.png --set-pixels '{\"color\":\"#FF0000\",\"width\":2,\"height\":2}'","handlingStrategy":"validation","validationCode":"import json\nsp = opts.get(\"set-pixels\")\nif sp is None:\n    raise SystemExit(\"set-pixels is required\")\nif isinstance(sp, str):\n    sp = json.loads(sp)\nif not isinstance(sp, dict):\n    raise SystemExit(\"set-pixels must be a JSON object\")","typeGuard":"def is_set_pixels_payload(v) -> bool:\n    if isinstance(v, str):\n        try:\n            v = json.loads(v)\n        except json.JSONDecodeError:\n            return False\n    return isinstance(v, dict)","tryCatchPattern":"try:\n    normalized = _normalize_set_pixels(value)\nexcept ValueError as e:\n    print_error(str(e)); sys.exit(1)","preventionTips":["Always pass set-pixels as a JSON object string at the CLI boundary.","Build the payload in code and json.dumps it rather than hand-writing strings."],"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"}