{"record":{"id":"44bd4f7c5079069a","repo":"hashicorp/packer","slug":"failed-fetching-enforced-blocks-for-bucket-q-w","errorCode":null,"errorMessage":"failed fetching enforced blocks for bucket %q: %w","messagePattern":"failed fetching enforced blocks for bucket %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/hcp/registry/types.bucket.go","lineNumber":174,"sourceCode":"// FetchEnforcedBlocks retrieves all enforced blocks linked to this bucket from HCP Packer.\n// These blocks contain provisioner configurations that should be automatically injected\n// into builds for this bucket.\nfunc (bucket *Bucket) FetchEnforcedBlocks(ctx context.Context) error {\n\tif bucket.client == nil {\n\t\treturn errors.New(\"bucket client not initialized, call Initialize first\")\n\t}\n\n\tlog.Printf(\"[INFO] fetching enforced blocks linked to bucket %q\", bucket.Name)\n\n\tresp, err := bucket.client.GetEnforcedBlocksForBucket(ctx, bucket.Name)\n\tif err != nil {\n\t\tif hcpPackerAPI.CheckErrorCode(err, codes.NotFound) || hcpPackerAPI.CheckErrorCode(err, codes.Unimplemented) {\n\t\t\t// If the API doesn't support enforced blocks yet or returns not found, continue silently.\n\t\t\tlog.Printf(\"[DEBUG] fetching enforced blocks for bucket %q: %v\", bucket.Name, err)\n\t\t\treturn nil\n\t\t}\n\n\t\treturn fmt.Errorf(\"failed fetching enforced blocks for bucket %q: %w\", bucket.Name, err)\n\t}\n\n\tif resp == nil {\n\t\tlog.Printf(\"[INFO] no enforced blocks response returned for bucket %q\", bucket.Name)\n\t\treturn nil\n\t}\n\n\tbucket.EnforcedBlocks = make([]*EnforcedBlock, 0, len(resp.EnforcedBlockDetail))\n\tfor _, detail := range resp.EnforcedBlockDetail {\n\t\tif detail == nil || detail.Version == nil {\n\t\t\tcontinue\n\t\t}\n\n\t\tblock := &EnforcedBlock{\n\t\t\tID:           detail.ID,\n\t\t\tName:         detail.Name,\n\t\t\tBlockContent: detail.Version.BlockContent,\n\t\t\tVersionID:    detail.Version.ID,","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/hashicorp/packer/blob/eb36e3c3e48a036f3e8cc94087636ee72e1303c9/internal/hcp/registry/types.bucket.go#L156-L192","documentation":"HCP registry error from Bucket.FetchEnforcedBlocks: the call to retrieve enforced blocks (mandatory provisioner configurations) for the bucket failed at the HCP API. Non-404 service errors land here; the wrapped error is the API response cause.","triggerScenarios":"Thrown at internal/hcp/registry/types.bucket.go:174 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check HCP service status and retry — this is often transient","Verify registry credentials have read access to the bucket's enforced blocks"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}