{"record":{"id":"44cc7b0a7624cfb7","repo":"kubernetes/kops","slug":"reading-data-w","errorCode":null,"errorMessage":"reading data: %w","messagePattern":"reading data: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"util/pkg/vfs/azureblob_terraform.go","lineNumber":37,"sourceCode":"import (\n\t\"fmt\"\n\t\"io\"\n\n\t\"k8s.io/kops/upup/pkg/fi/cloudup/terraformWriter\"\n)\n\ntype terraformAzureBlobFile struct {\n\tName               string                   `cty:\"name\"`\n\tStorageContainerID string                   `cty:\"storage_container_id\"`\n\tType               string                   `cty:\"type\"`\n\tSource             *terraformWriter.Literal `cty:\"source\"`\n\tProvider           *terraformWriter.Literal `cty:\"provider\"`\n}\n\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,","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/util/pkg/vfs/azureblob_terraform.go#L19-L55","documentation":"In kOps' VFS layer, AzureBlobPath.RenderTerraform writes a blob resource into generated Terraform output. Before doing so it slurps the blob contents from the io.Reader passed in; if that read fails (e.g. an underlying reader error), the read error is wrapped as \"reading data: %w\" so the original cause is preserved for the caller.","triggerScenarios":"Calling RenderTerraform on an *AzureBlobPath where the `data io.Reader` argument returns a non-nil error from io.ReadAll — e.g. a reader backed by a file that cannot be opened/read, a network-backed reader, or a reader already consumed/closed.","commonSituations":"The local file backing the VFS path was deleted or permission-denied before rendering; a bytes.Reader wrapped around a failed asset load; a custom io.Reader implementation erroring mid-read during `kops update cluster --target=terraform`.","solutions":["Inspect the wrapped cause (%w) in the error chain with errors.Unwrap/ %v to see why the read failed","Verify the source data exists and is readable before calling RenderTerraform","Ensure the io.Reader is freshly opened and not already exhausted (check for io.EOF consumed earlier)","Re-run the kops update command after fixing the input file"],"exampleFix":"// before\nf, _ := os.Open(path)\ndefer f.Close()\np.RenderTerraform(w, name, f, acl)\n\n// after\nf, err := os.Open(path)\nif err != nil {\n\treturn fmt.Errorf(\"opening blob source %q: %w\", path, err)\n}\ndefer f.Close()\nif _, err := f.Stat(); err != nil {\n\treturn fmt.Errorf(\"blob source %q unreadable: %w\", path, err)\n}\nreturn p.RenderTerraform(w, name, f, acl)","handlingStrategy":"try-catch","validationCode":"if f, ok := data.(*os.File); ok {\n\tif _, err := f.Stat(); err != nil {\n\t\treturn fmt.Errorf(\"blob source unreadable: %w\", err)\n\t}\n}","typeGuard":null,"tryCatchPattern":"err := p.RenderTerraform(w, name, data, acl)\nif err != nil && strings.Contains(err.Error(), \"reading data:\") {\n\tcause := errors.Unwrap(err)\n\tlog.Printf(\"blob data read failed: %v\", cause)\n\t// fix or re-open the source reader, then retry\n}","preventionTips":["Open and verify (Stat/read a probe) the source before handing the reader to RenderTerraform","Never reuse an already-consumed reader; create a fresh reader per render","Wrap custom io.Reader implementations to surface errors early"],"tags":["terraform","azure","vfs","io-error"],"backgroundTag":"io-read-failed","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}