{"record":{"id":"841f67b8e56157de","repo":"hashicorp/packer","slug":"failed-to-upload-sboms-s","errorCode":null,"errorMessage":"Failed to upload sboms %s","messagePattern":"Failed to upload sboms (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/hcp/registry/types.bucket.go","lineNumber":811,"sourceCode":"\t\t}\n\t}\n\n\tbuild, err := bucket.Version.Build(buildName)\n\tif err != nil {\n\t\treturn packerSDKArtifacts, fmt.Errorf(\n\t\t\t\"failed to get build %q from version being built. This is a Packer bug.\",\n\t\t\tbuildName)\n\t}\n\tif len(build.Artifacts) == 0 {\n\t\treturn packerSDKArtifacts, &NotAHCPArtifactError{\n\t\t\tfmt.Errorf(\"No HCP Packer-compatible artifacts were found for the build\"),\n\t\t}\n\t}\n\n\tfor _, sbom := range build.CompressedSboms {\n\t\terr = bucket.uploadSbom(ctx, buildName, sbom)\n\t\tif err != nil {\n\t\t\treturn packerSDKArtifacts, fmt.Errorf(\"Failed to upload sboms %s\", err)\n\t\t}\n\t}\n\n\tparErr := bucket.markBuildComplete(ctx, buildName)\n\tif parErr != nil {\n\t\treturn packerSDKArtifacts, fmt.Errorf(\n\t\t\t\"failed to update HCP Packer artifacts for %q: %s\",\n\t\t\tbuildName,\n\t\t\tparErr)\n\t}\n\n\t// Update channels after build is marked complete\n\tchannelErr := bucket.updateChannels(ctx, ui)\n\tif channelErr != nil {\n\t\tlog.Printf(\"[ERROR] Failed to update channels after completing build %s: %s\", buildName, channelErr)\n\t}\n\n\treturn append(packerSDKArtifacts, &registryArtifact{","sourceCodeStart":793,"sourceCodeEnd":829,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/internal/hcp/registry/types.bucket.go#L793-L829","documentation":"Wraps a failure from bucket.uploadSbom when publishing compressed SBOM entries for a build to HCP Packer. It indicates one or more SBOM uploads failed during doCompleteBuild, typically due to an API/network problem or an oversized/invalid SBOM payload.","triggerScenarios":"doCompleteBuild iterates build.CompressedSboms calling uploadSbom; any non-nil error from that call (HTTP failure, auth expiry, size limit, malformed SBOM) is wrapped as 'Failed to upload sboms %s'.","commonSituations":"Transient HCP API outages or timeouts during build completion; expired/invalid HCP credentials; very large SBOM payloads exceeding service limits; corrupted SBOM generation by a data source.","solutions":["Re-run the build; SBOM upload failures are often transient API issues","Check HCP credentials (HCP_CLIENT_ID/HCP_CLIENT_SECRET) and network/proxy connectivity to api.cloud.hashicorp.com","Verify SBOM content is valid and not exceeding size limits; disable the SBOM-generating data source if not needed","Inspect the wrapped error text (it is appended via %s) to identify the underlying HTTP status"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-flight: verify HCP API reachability and credentials before long builds\nresp, err := http.Get(\"https://api.cloud.hashicorp.com\")\nif err != nil { log.Warn(\"HCP API unreachable; SBOM uploads may fail\") }","typeGuard":null,"tryCatchPattern":"if err := run(); err != nil {\n    var na *registry.NotAHCPArtifactError\n    if errors.As(err, &na) { /* not SBOM-related */ }\n    if strings.Contains(err.Error(), \"Failed to upload sboms\") {\n        // inspect wrapped cause, retry build or skip SBOM publishing\n    }\n}","preventionTips":["Keep HCP credentials valid for the whole build duration","Check HCP service status before long-running builds that publish SBOMs","Keep SBOM payloads within service size limits"],"tags":["hcp-packer","sbom","upload","network"],"backgroundTag":"sbom-upload-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"}