{"record":{"id":"9ca85812f49398ec","repo":"kubernetes/kops","slug":"rendering-azure-blob-file-w-9ca858","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/memfs.go","lineNumber":254,"sourceCode":"\tProvider *terraformWriter.Literal `json:\"provider,omitempty\" cty:\"provider\"`\n}\n\nfunc (p *MemFSPath) RenderTerraform(w *terraformWriter.TerraformWriter, name string, data io.Reader, acl ACL) error {\n\tif w.Providers != nil && w.Providers[\"azurerm\"] != nil {\n\t\treturn p.renderTerraformAzure(w, name, data)\n\t}\n\treturn p.renderTerraformS3(w, name, data, acl)\n}\n\nfunc (p *MemFSPath) renderTerraformAzure(w *terraformWriter.TerraformWriter, name string, data io.Reader) error {\n\tbytes, err := io.ReadAll(data)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"reading data: %v\", err)\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\t// memfs:// paths don't encode an Azure account or container, so this\n\t// fallback (only used in integration tests) hard-codes a test placeholder\n\t// container on the storage account from the cluster spec.\n\ttf := &terraformAzureBlobFile{\n\t\tName:               p.location,\n\t\tStorageContainerID: w.AzureStorageAccountID + \"/blobServices/default/containers/testcontainer\",\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\nfunc (p *MemFSPath) renderTerraformS3(w *terraformWriter.TerraformWriter, name string, data io.Reader, acl ACL) error {\n\tbytes, err := io.ReadAll(data)\n\tif err != nil {","sourceCodeStart":236,"sourceCodeEnd":272,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/util/pkg/vfs/memfs.go#L236-L272","documentation":"After reading the bytes, renderTerraformAzure registers the blob content with the TerraformWriter via AddFilePath for resource azurerm_storage_blob. This error wraps any failure returned by that writer call (e.g. duplicate resource name or internal writer error).","triggerScenarios":"RenderTerraform -> renderTerraformAzure where w.AddFilePath rejects the file — commonly because two files render under the same resource name, or the writer's internal map/lock rejects the add.","commonSituations":"Azure terraform output tests where multiple memfs paths collide on the same 'name' argument; bugs in caller-provided naming producing duplicate terraform resources.","solutions":["Check the wrapped error from AddFilePath; if it reports a duplicate, make the resource 'name' unique per path","Ensure RenderTerraform is not invoked twice over the same writer with identical names without a fresh writer","Inspect the terraformWriter implementation for the exact rejection reason and fix the caller accordingly"],"exampleFix":"// before\nw.AddFilePath(\"azurerm_storage_blob\", name, \"source\", bytes, false) // name duplicates another resource\n// after\nuniqueName := strings.ReplaceAll(strings.TrimPrefix(string(p), \"memfs://\"), \"/\", \"__\")\nw.AddFilePath(\"azurerm_storage_blob\", uniqueName, \"source\", bytes, false)","handlingStrategy":"validation","validationCode":"if name == \"\" || seen[name] { name = uniquify(name) }; seen[name] = true","typeGuard":"null","tryCatchPattern":"if err := p.RenderTerraform(w, name, data, nil); err != nil {\n    if strings.Contains(err.Error(), \"rendering Azure Blob file\") {\n        klog.Errorf(\"terraform blob add failed for %s: %v\", name, err)\n    }\n    return err\n}","preventionTips":["Ensure resource names passed to RenderTerraform are unique per blob","Use a fresh TerraformWriter per render pass","Match kops naming conventions for rendered resources"],"tags":["vfs","memfs","terraform","azure"],"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"}