{"record":{"id":"388645339479e525","repo":"anomalyco/sst","slug":"invalid-artifact-json-stringify-artifact","errorCode":null,"errorMessage":"Invalid artifact: ${JSON.stringify(artifact)}","messagePattern":"Invalid artifact: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"sdk/js/scripts/release.ts","lineNumber":36,"sourceCode":"console.log(\"publishing\", nextPkg.version);\n\nawait fs.rmdir(\"dist\", { recursive: true }).catch(() => {});\nawait $`bun run build`;\n\nconst cpus = {\n  arm64: \"arm64\",\n  amd64: \"x64\",\n  \"386\": \"x86\",\n};\n\nconst tmp = `tmp`;\nconst binaryPackages = [] as string[];\nfor (const artifact of artifacts) {\n  if (artifact.type !== \"Binary\") continue;\n  const os = artifact.goos === \"windows\" ? \"win32\" : artifact.goos;\n  const cpu = cpus[artifact.goarch as keyof typeof cpus];\n  if (!os || !cpu)\n    throw new Error(`Invalid artifact: ${JSON.stringify(artifact)}`);\n  const name = `${pkg.name}-${os}-${cpu}`;\n  const dir = path.join(tmp, name);\n  const binary = path.basename(artifact.path);\n  await fs.mkdir(path.join(dir, \"bin\"), { recursive: true });\n  await fs.cp(\n    path.join(\"../../\", artifact.path),\n    path.join(dir, \"bin\", binary),\n  );\n  Bun.write(\n    path.join(dir, \"package.json\"),\n    JSON.stringify(\n      {\n        name,\n        version: nextPkg.version,\n        license: nextPkg.license,\n        repository: nextPkg.repository,\n        os: [os],\n        cpu: [cpu],","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/sdk/js/scripts/release.ts#L18-L54","documentation":"The SDK release script processes goreleaser artifacts, mapping each binary artifact's goos/goarch to Node platform identifiers (windows→win32, goarch via a cpus lookup table). This error is thrown when a binary artifact's OS or CPU architecture cannot be mapped to a known npm platform, i.e. goreleaser produced a target the release script doesn't recognize.","triggerScenarios":"Running the SDK release script (sdk/js/scripts/release.ts) with a goreleaser artifacts.json that contains a binary artifact whose goos is not windows/linux/darwin (e.g. freebsd, wasip1) or whose goarch is not in the cpus table (e.g. riscv64, loong64, mips), so `os` or `cpu` resolves to undefined.","commonSituations":"Adding a new GOOS/GOARCH target to .goreleaser.yml without updating the release script's mappings; goreleaser upgrading and emitting new default targets; a partially-filled or hand-edited artifacts.json; running the script against artifacts from a different project.","solutions":["Remove the unsupported GOOS/GOARCH target from .goreleaser.yml, or restrict builds to targets the script knows (linux/darwin/windows × amd64/arm64).","Update the release script's os mapping and cpus table in sdk/js/scripts/release.ts to handle the new goos/goarch, mapping it to the matching npm platform (e.g. freebsd → 'freebsd' if publishing that package).","Inspect the artifact JSON in the error message to see exactly which field is unmapped (goos vs goarch).","Re-run goreleaser so artifacts.json is fresh and matches the current release config before running the script."],"exampleFix":"// before (.goreleaser.yml)\ngoarch: [amd64, arm64, riscv64]\n// after\ngoarch: [amd64, arm64]  // or add riscv64 to the cpus table in release.ts","handlingStrategy":"validation","validationCode":"const KNOWN_OS = new Set([\"linux\", \"darwin\", \"windows\"]);\nconst KNOWN_ARCH = new Set([\"amd64\", \"arm64\"]);\nfor (const a of artifacts.filter(a => a.type === \"Binary\")) {\n  if (!KNOWN_OS.has(a.goos) || !KNOWN_ARCH.has(a.goarch))\n    throw new Error(`Unmapped artifact target: ${a.goos}/${a.goarch}`);\n}","typeGuard":"function isMappableArtifact(a: { type: string; goos: string; goarch: string }): boolean {\n  return [\"linux\", \"darwin\", \"windows\"].includes(a.goos) && [\"amd64\", \"arm64\"].includes(a.goarch);\n}","tryCatchPattern":"try {\n  await runRelease(artifacts);\n} catch (e) {\n  if ((e as Error).message.startsWith(\"Invalid artifact:\")) {\n    console.error(\"Add or remove this GOOS/GOARCH target in .goreleaser.yml / release.ts mappings\");\n    process.exit(1);\n  }\n  throw e;\n}","preventionTips":["Keep .goreleaser.yml targets in sync with the os/cpus lookup tables in sdk/js/scripts/release.ts.","Pin goreleaser versions so new default targets don't appear unexpectedly.","Review artifacts.json after goreleaser runs and before invoking the release script.","Restrict release targets to well-known npm platforms: linux/darwin/windows × amd64/arm64."],"tags":["release","ci","build","goreleaser"],"backgroundTag":"unsupported-release-target","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}