{"record":{"id":"ab3af919a2cc60a1","repo":"hashicorp/packer","slug":"generate-sbom-w","errorCode":null,"errorMessage":"generate SBOM: %w","messagePattern":"generate SBOM: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"post-processor/provenance/post-processor.go","lineNumber":466,"sourceCode":"\t// artifact changed between runs.\n\tformat, err := internalsbom.ParseFormatFromArgs(p.config.SBOMFormat)\n\tif err != nil {\n\t\treturn \"\", nil, err\n\t}\n\n\tscanPath, err := p.resolveSBOMScanPath(source)\n\tif err != nil {\n\t\treturn \"\", nil, err\n\t}\n\n\trawSBOM, err := p.generateSBOM(ctx, internalsbom.Config{\n\t\tScanPath: scanPath,\n\t\tFormat:   format,\n\t\tScope:    p.config.SBOMScope,\n\t\tExclude:  append([]string(nil), p.config.SBOMExclude...),\n\t})\n\tif err != nil {\n\t\treturn \"\", nil, fmt.Errorf(\"generate SBOM: %w\", err)\n\t}\n\n\tif err := atomicWriteFile(paths.SBOMRaw, rawSBOM, 0664); err != nil {\n\t\treturn \"\", nil, fmt.Errorf(\"write SBOM %q: %w\", paths.SBOMRaw, err)\n\t}\n\n\treturn format, rawSBOM, nil\n}\n\nfunc (p *PostProcessor) resolveSBOMScanPath(source packersdk.Artifact) (string, error) {\n\tif p.config.SBOMScanPath != \"\" {\n\t\treturn p.config.SBOMScanPath, nil\n\t}\n\n\tfiles := source.Files()\n\tif len(files) == 1 {\n\t\treturn files[0], nil\n\t}","sourceCodeStart":448,"sourceCodeEnd":484,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/post-processor/provenance/post-processor.go#L448-L484","documentation":"Runtime error from resolveSBOM in the provenance post-processor: generating the SBOM for the artifact (via the configured scanner, e.g. Syft) failed. The wrapped error carries the scanner's failure — bad scope, missing scanner binary, or unreadable scan path.","triggerScenarios":"writeSBOMAttestation -> resolveSBOM invokes the SBOM generator with ScanPath/Format/Scope/Exclude and it returns an error; the raw SBOM is then never written.","commonSituations":"scan_path points to a nonexistent artifact/directory; unsupported SBOM format requested; scanner binary missing or its version incompatible; scan scope invalid; exclude patterns malformed.","solutions":["Check sbom_scope/sbom_exclude settings and that the scan path exists","Verify the SBOM scanner tool is installed and runnable","Inspect the wrapped error for the scanner-specific cause and fix accordingly"],"exampleFix":"// before\n\"sbom\": {\n  \"scan_path\": \"/nonexistent/dir\"\n}\n// after\n\"sbom\": {\n  \"scan_path\": \"./output/image.tar\"\n}","handlingStrategy":"try-catch","validationCode":"import os\nfunc checkScanTarget(scanPath, format string) error {\n\tif _, err := os.Stat(scanPath); err != nil {\n\t\treturn fmt.Errorf(\"scan_path %s unavailable: %w\", scanPath, err)\n\t}\n\tswitch format {\n\tcase \"spdx-json\", \"cyclonedx-json\":\n\t\treturn nil\n\tdefault:\n\t\treturn fmt.Errorf(\"unsupported SBOM format %q\", format)\n\t}\n}","typeGuard":null,"tryCatchPattern":"if err := p.PostProcess(ctx, a); err != nil {\n\tif strings.Contains(err.Error(), \"generate SBOM\") {\n\t\tlog.Printf(\"SBOM generation failed; check scanner and scan_path: %v\", err)\n\t}\n\treturn err\n}","preventionTips":["Verify scan_path exists after the build (artifact output dir).","Pin/install the SBOM scanner binary in CI images.","Use only supported SBOM formats.","Test sbom_exclude patterns on a sample artifact first."],"tags":["sbom","generator","provenance"],"backgroundTag":"sbom-generation-failed","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"}