{"record":{"id":"d804f52b083647e0","repo":"oven-sh/bun","slug":"unsupported-os-cloudinit-os","errorCode":null,"errorMessage":"Unsupported os: ${cloudInit[\"os\"]}","messagePattern":"Unsupported os: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/machine.mjs","lineNumber":680,"sourceCode":"  let sftpPath = \"/usr/lib/openssh/sftp-server\";\n  let shell = \"/bin/bash\";\n  switch (cloudInit[\"distro\"]) {\n    case \"alpine\":\n      sftpPath = \"/usr/lib/ssh/sftp-server\";\n      break;\n    case \"amazonlinux\":\n    case \"rhel\":\n    case \"centos\":\n      sftpPath = \"/usr/libexec/openssh/sftp-server\";\n      break;\n  }\n  switch (cloudInit[\"os\"]) {\n    case \"linux\":\n    case \"windows\":\n      // handled above\n      break;\n    default:\n      throw new Error(`Unsupported os: ${cloudInit[\"os\"]}`);\n  }\n\n  let users;\n  if (username === \"root\") {\n    users = [`root:${password}`];\n  } else {\n    users = [`root:${password}`, `${username}:${password}`];\n  }\n\n  // https://cloudinit.readthedocs.io/en/stable/\n  return `#cloud-config\nusers:\n  - name: ${username}\n    sudo: ALL=(ALL) NOPASSWD:ALL\n    shell: ${shell}\n    ssh_authorized_keys:\n${authorizedKeys.map(key => `      - ${key}`).join(\"\\n\")}\n","sourceCodeStart":662,"sourceCodeEnd":698,"githubUrl":"https://github.com/oven-sh/bun/blob/8c5296ac459e8252d3cd702f3fbcbb0c249d95d5/scripts/machine.mjs#L662-L698","documentation":"generateCloudInit() ends with a validation switch on cloudInit['os']: only 'linux' and 'windows' pass; every other value (including 'darwin'/'macos', undefined, or a typo) falls to default and throws. It's a fail-fast guard before emitting the #cloud-config user-data.","triggerScenarios":"A machine config with os 'macos'/'darwin' reaching the AWS cloud-init generator; os key missing from the config object so it's undefined; casing/typo like 'Linux' or 'linnux'.","commonSituations":"A tart (macOS) machine spec accidentally routed through the AWS path; hand-edited machine YAML dropping the os field.","solutions":["Set os to 'linux' or 'windows' in the machine/cloudInit config","Route darwin machines to the tart provider instead of AWS cloud-init","Validate os earlier in the pipeline (see type guard) so the failure surfaces at config parse time"],"exampleFix":"// before\nconst userData = generateCloudInit({ os: 'macos', ... });\n\n// after\nconst userData = generateCloudInit({ os: 'linux', ... });","handlingStrategy":"validation","validationCode":"const os = cloudInit['os'];\nif (os !== 'linux' && os !== 'windows') {\n  throw new Error(`cloudInit os must be 'linux' or 'windows', got: ${os}`);\n}","typeGuard":"function isCloudInitOs(v) {\n  return v === 'linux' || v === 'windows';\n}","tryCatchPattern":null,"preventionTips":["Set the os field explicitly in every machine spec — never rely on defaults for user-data generation","Keep darwin/macos machines on the tart path which doesn't use cloud-init","Validate enum-ish fields at the config boundary, before any cloud API is called"],"tags":["cloud-init","config","validation","provisioning"],"backgroundTag":null,"analyzedSha":"8c5296ac459e8252d3cd702f3fbcbb0c249d95d5","analyzedAt":"2026-08-16T08:01:58.794Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}