{"record":{"id":"7ea0c583a15c3a69","repo":"kubernetes/kops","slug":"rendering-azure-blob-file-w","errorCode":null,"errorMessage":"rendering Azure Blob file: %w","messagePattern":"rendering Azure Blob file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"util/pkg/vfs/azureblob_terraform.go","lineNumber":51,"sourceCode":"\nfunc (p *AzureBlobPath) RenderTerraform(w *terraformWriter.TerraformWriter, name string, data io.Reader, acl ACL) error {\n\tbytes, err := io.ReadAll(data)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"reading data: %w\", err)\n\t}\n\n\tw.EnsureTerraformProvider(\"azurerm\", map[string]string{})\n\n\tif p.account == \"\" {\n\t\treturn fmt.Errorf(\"Azure storage account is not set on path %q\", p.Path())\n\t}\n\tif w.AzureStorageAccountID == \"\" {\n\t\treturn fmt.Errorf(\"Azure storage account ID is not set; it is required to render blob %q\", p.Path())\n\t}\n\n\tsource, err := w.AddFilePath(\"azurerm_storage_blob\", name, \"source\", bytes, false)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"rendering Azure Blob file: %w\", err)\n\t}\n\n\ttf := &terraformAzureBlobFile{\n\t\tName:               p.key,\n\t\tStorageContainerID: w.AzureStorageAccountID + \"/blobServices/default/containers/\" + p.container,\n\t\tType:               \"Block\",\n\t\tSource:             source,\n\t\tProvider:           terraformWriter.LiteralTokens(\"azurerm\", \"files\"),\n\t}\n\treturn w.RenderResource(\"azurerm_storage_blob\", name, tf)\n}\n","sourceCodeStart":33,"sourceCodeEnd":63,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/util/pkg/vfs/azureblob_terraform.go#L33-L63","documentation":"After validation, RenderTerraform registers the blob's file contents with the TerraformWriter via w.AddFilePath(\"azurerm_storage_blob\", ...), which stores the content and returns the Terraform source reference. If AddFilePath fails, the error is wrapped as \"rendering Azure Blob file: %w\", indicating the blob resource could not be added to the generated Terraform.","triggerScenarios":"Calling RenderTerraform on an *AzureBlobPath where the writer's AddFilePath call returns an error — e.g. the writer's file-store is closed/failed, duplicate resource names, or internal hashing/writing of the blob bytes fails.","commonSituations":"Rendering very large blobs that exceed writer limits; name collisions for the azurerm_storage_blob resource in the same Terraform output; using a TerraformWriter that previously hit an error and is in a bad state.","solutions":["Inspect the wrapped error from AddFilePath (errors.Unwrap) for the root cause","Ensure each blob is rendered with a unique `name` to avoid duplicate Terraform resource entries","Check blob content size and validity before rendering","Recreate/reinitialize the TerraformWriter and re-run the render"],"exampleFix":"// before\nw.AddFilePath(\"azurerm_storage_blob\", name, \"source\", bytes, false) // name reused across blobs\n\n// after\nuniqueName := fmt.Sprintf(\"%s-%s\", container, strings.ReplaceAll(key, \"/\", \"-\"))\nif err := p.RenderTerraform(w, uniqueName, data, acl); err != nil {\n\treturn fmt.Errorf(\"rendering blob %q: %w\", p.Path(), err)\n}","handlingStrategy":"try-catch","validationCode":"if name == \"\" {\n\treturn fmt.Errorf(\"blob resource name must be non-empty and unique\")\n}\nif len(bytes) == 0 {\n\tlog.Printf(\"warning: rendering empty blob %s\", name)\n}","typeGuard":null,"tryCatchPattern":"if err := p.RenderTerraform(w, name, data, acl); err != nil {\n\tvar wrapped error\n\tif strings.Contains(err.Error(), \"rendering Azure Blob file:\") {\n\t\twrapped = errors.Unwrap(err)\n\t\tlog.Printf(\"AddFilePath failed for blob %q: %v\", p.Path(), wrapped)\n\t}\n\treturn err\n}","preventionTips":["Use unique, deterministic Terraform resource names per blob (container+key derived)","Keep the TerraformWriter single-use per output directory to avoid corrupted state","Test rendering with representative blob sizes before production cluster updates"],"tags":["azure","terraform","vfs","rendering"],"backgroundTag":"terraform-render-failed","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}