{"record":{"id":"d1253581ae3d4bfd","repo":"hashicorp/packer","slug":"sbom-generation-is-not-supported-on-s-builds","errorCode":null,"errorMessage":"sbom generation is not supported on %s builds","messagePattern":"sbom generation is not supported on (.+?) builds","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sbom/generator_unsupported.go","lineNumber":17,"sourceCode":"// Copyright IBM Corp. 2013, 2025\n// SPDX-License-Identifier: BUSL-1.1\n\n//go:build netbsd || openbsd || solaris || mips || mipsle || mips64 || (freebsd && (386 || arm))\n\npackage sbom\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"runtime\"\n)\n\n// Generate returns an error on platforms where the Syft SDK cannot be built.\nfunc (g *Generator) Generate(ctx context.Context) ([]byte, error) {\n\t_ = ctx\n\treturn nil, fmt.Errorf(\"sbom generation is not supported on %s builds\", runtime.GOOS)\n}\n","sourceCodeStart":1,"sourceCodeEnd":19,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/internal/sbom/generator_unsupported.go#L1-L19","documentation":"On operating systems where the Syft SDK cannot be compiled (build-tag constrained platforms), internal/sbom swaps in generator_unsupported.go whose Generator.Generate unconditionally fails with \"sbom generation is not supported on %s builds\", reporting runtime.GOOS. This is a compile-time capability limitation surfaced as a runtime error, not a user configuration mistake.","triggerScenarios":"Calling Generator.Generate on a GOOS for which the syft-based generator file is excluded by build tags (e.g. building Packer for an OS/arch the syft SDK does not support). The call always returns this error on such builds regardless of config.","commonSituations":"Cross-compiling Packer to an exotic platform; running a community build of packer for an OS without syft support and enabling an SBOM-generating feature; CI matrices that build for unsupported GOOS values.","solutions":["Run Packer on a supported GOOS (linux/darwin/windows) where the syft-backed generator is compiled in","Skip or guard the SBOM feature with a GOOS check before invoking Generate","Generate the SBOM out-of-band with the syft CLI on a supported platform and feed the artifact in","If support for the platform is needed, upstream syft build support or adjust the build tags"],"exampleFix":"// before\nsbomBytes, err := gen.Generate(ctx)\n// after\nif runtime.GOOS == \"plan9\" {\n    log.Println(\"sbom generation unsupported on this platform; skipping\")\n} else {\n    sbomBytes, err = gen.Generate(ctx)\n}","handlingStrategy":"fallback","validationCode":"// Compile-time note: use a build-tagged file to provide a no-op generator on unsupported GOOS\n//go:build plan9 || js\n// In code: check the platform before calling\nunsupported := runtime.GOOS == \"plan9\" || runtime.GOOS == \"js\"","typeGuard":null,"tryCatchPattern":"sbomBytes, err := gen.Generate(ctx)\nif err != nil && strings.Contains(err.Error(), \"sbom generation is not supported\") {\n    log.Printf(\"skipping SBOM on %s\", runtime.GOOS)\n    return nil\n}","preventionTips":["Guard SBOM features with runtime.GOOS checks or build tags in CI matrices","Test cross-compilation targets before shipping platform builds","Provide a documented fallback (external syft CLI) for unsupported platforms"],"tags":["sbom","platform","build-tags","syft"],"backgroundTag":"unsupported-platform-feature","analyzedSha":"eb36e3c3e48a036f3e8cc94087636ee72e1303c9","analyzedAt":"2026-09-05T13:20:43.127Z","contentChangedAt":"2026-09-05T13:20:43.127Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}