{"record":{"id":"c571e36ae75b3d87","repo":"windmill-labs/windmill","slug":"file-path-is-encoded-as-utf-32-le-which-is-not","errorCode":null,"errorMessage":"File ${path} is encoded as UTF-32 LE, which is not supported. Please convert it to UTF-8.","messagePattern":"File (.+?) is encoded as UTF-32 LE, which is not supported\\. Please convert it to UTF-8\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/src/utils/utils.ts","lineNumber":139,"sourceCode":"}\n\nexport async function generateHash(content: string): Promise<string> {\n  const messageBuffer = new TextEncoder().encode(content);\n  return await generateHashFromBuffer(messageBuffer);\n}\n\nexport async function generateHashFromBuffer(\n  content: BufferSource\n): Promise<string> {\n  const hashBuffer = await crypto.subtle.digest(\"SHA-256\", content);\n  return Buffer.from(hashBuffer).toString(\"hex\");\n}\n\nfunction decodeBufferAsUtf8(buf: Buffer, path: string | URL): string {\n  if (buf.length >= 2) {\n    if (buf[0] === 0xff && buf[1] === 0xfe) {\n      if (buf.length >= 4 && buf[2] === 0x00 && buf[3] === 0x00) {\n        throw new Error(\n          `File ${path} is encoded as UTF-32 LE, which is not supported. Please convert it to UTF-8.`\n        );\n      }\n      throw new Error(\n        `File ${path} is encoded as UTF-16 LE, which is not supported. Please convert it to UTF-8.`\n      );\n    }\n    if (buf[0] === 0xfe && buf[1] === 0xff) {\n      throw new Error(\n        `File ${path} is encoded as UTF-16 BE, which is not supported. Please convert it to UTF-8.`\n      );\n    }\n    if (buf.length >= 4 && buf[0] === 0x00 && buf[1] === 0x00 && buf[2] === 0xfe && buf[3] === 0xff) {\n      throw new Error(\n        `File ${path} is encoded as UTF-32 BE, which is not supported. Please convert it to UTF-8.`\n      );\n    }\n  }","sourceCodeStart":121,"sourceCodeEnd":157,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/cli/src/utils/utils.ts#L121-L157","documentation":"`decodeBufferAsUtf8` in the windmill CLI checks a file's byte-order mark (BOM) before decoding it as UTF-8. Files saved as UTF-32 LE (BOM FF FE 00 00) are rejected outright because the tooling only supports UTF-8 (with optional UTF-8 BOM).","triggerScenarios":"Reading any file via `readTextFile`/`readTextFileSync` (e.g. a YAML script or flow definition) whose first bytes are FF FE 00 00.","commonSituations":"Files created or re-saved by Windows Notepad or PowerShell (`Out-File`) writing UTF-32; files converted between encodings incorrectly.","solutions":["Re-save the file as UTF-8 (VS Code: 'Save with Encoding' → UTF-8)","Convert in place: `iconv -f UTF-32LE -t UTF-8 file > file.tmp && mv file.tmp file`","On PowerShell: `Get-Content file | Set-Content -Encoding utf8 file`"],"exampleFix":"// before (PowerShell)\n\"content\" | Out-File script.yaml -Encoding UTF32\n// after\n\"content\" | Out-File script.yaml -Encoding utf8BOM","handlingStrategy":"validation","validationCode":"const fs = require('fs');\nfunction assertNotUtf32Le(path) {\n  const b = fs.readFileSync(path).subarray(0, 4);\n  if (b[0] === 0xff && b[1] === 0xfe && b[2] === 0x00 && b[3] === 0x00)\n    throw new Error(`${path} is UTF-32 LE; convert to UTF-8 first`);\n}","typeGuard":"function isUtf32Le(buf) {\n  return buf.length >= 4 && buf[0] === 0xff && buf[1] === 0xfe && buf[2] === 0x00 && buf[3] === 0x00;\n}","tryCatchPattern":"try {\n  const content = await readTextFile(path);\n} catch (e) {\n  if (String(e.message).includes('UTF-32 LE')) console.error('Convert the file to UTF-8 (iconv -f UTF-32LE -t UTF-8).');\n  else throw e;\n}","preventionTips":["Configure editors and shell redirections to write UTF-8 (PowerShell: -Encoding utf8)","Check file encodings with `file <path>` before feeding files to the CLI","Avoid legacy Windows 'Unicode'/'UTF-32' save options in Notepad/PowerShell 5"],"tags":["encoding","utf-32","file","bom"],"backgroundTag":"unsupported-file-encoding","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}