{"record":{"id":"b3a90a38462d5cd7","repo":"windmill-labs/windmill","slug":"file-path-is-encoded-as-utf-32-be-which-is-not","errorCode":null,"errorMessage":"File ${path} is encoded as UTF-32 BE, which is not supported. Please convert it to UTF-8.","messagePattern":"File (.+?) is encoded as UTF-32 BE, 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":153,"sourceCode":"function 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  }\n  if (buf.length >= 3 && buf[0] === 0xef && buf[1] === 0xbb && buf[2] === 0xbf) {\n    return buf.subarray(3).toString(\"utf-8\");\n  }\n  return buf.toString(\"utf-8\");\n}\n\nexport function stripBom(content: string): string {\n  if (content.charCodeAt(0) === 0xfeff) {\n    return content.slice(1);\n  }\n  return content;\n}\n\nexport async function readTextFile(path: string | URL): Promise<string> {","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/cli/src/utils/utils.ts#L135-L171","documentation":"Sentinel guard in decodeBufferAsUtf8: the file starts with the UTF-32 BE BOM (00 00 FE FF); the CLI only accepts UTF-8, so reading is refused rather than producing mojibake. The input at fault is the file's encoding.","triggerScenarios":"Reading a file via `readTextFile`/`readTextFileSync` whose first four bytes are 00 00 FE FF.","commonSituations":"Files exported by tools that default to UTF-32 (rare, e.g. some Unix utilities or misconfigured converters); files corrupted during encoding conversion.","solutions":["Re-save the file as UTF-8","Convert: `iconv -f UTF-32BE -t UTF-8 file > file.tmp && mv file.tmp file`","Verify with `file <path>` that the result is now 'UTF-8 Unicode text'"],"exampleFix":"// before\nfile f.yaml  # data\n// after\niconv -f UTF-32BE -t UTF-8 f.yaml > /tmp/f.tmp && mv /tmp/f.tmp f.yaml","handlingStrategy":"validation","validationCode":"const fs = require('fs');\nfunction assertNotUtf32Be(path) {\n  const b = fs.readFileSync(path).subarray(0, 4);\n  if (b[0] === 0x00 && b[1] === 0x00 && b[2] === 0xfe && b[3] === 0xff)\n    throw new Error(`${path} is UTF-32 BE; convert to UTF-8 first`);\n}","typeGuard":"function isUtf32Be(buf) {\n  return buf.length >= 4 && buf[0] === 0x00 && buf[1] === 0x00 && buf[2] === 0xfe && buf[3] === 0xff;\n}","tryCatchPattern":"try {\n  const content = await readTextFile(path);\n} catch (e) {\n  if (String(e.message).includes('UTF-32 BE')) console.error('Convert with: iconv -f UTF-32BE -t UTF-8 <file>');\n  else throw e;\n}","preventionTips":["UTF-32 files are rare — treat any 'UTF-32' tool output as a red flag and re-export as UTF-8","Verify encodings with `file` in pipelines before CLI consumption","Standardize on UTF-8 (no BOM or UTF-8 BOM is accepted) across the team"],"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"}