{"record":{"id":"1fe15017b7a2d439","repo":"hashicorp/terraform","slug":"can-t-read-s-v","errorCode":null,"errorMessage":"can't read %s: %v","messagePattern":"can't read (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/backend/remote-state/oci/auth.go","lineNumber":337,"sourceCode":"\t\t\tDialContext: (&net.Dialer{\n\t\t\t\tTimeout: getDurationFromEnvVar(DialContextConnectionTimeout, DefaultConnectionTimeout),\n\t\t\t}).DialContext,\n\t\t\tTLSHandshakeTimeout: getDurationFromEnvVar(TLSHandshakeTimeout, DefaultTLSHandshakeTimeout),\n\t\t\tTLSClientConfig:     &tls.Config{MinVersion: tls.VersionTLS12},\n\t\t\tProxy:               http.ProxyFromEnvironment,\n\t\t},\n\t}\n\treturn\n}\n\nfunc getCertificateFileBytes(certificateFileFullPath string) (pemRaw []byte, err error) {\n\tabsFile, err := filepath.Abs(certificateFileFullPath)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"can't form absolute path of %s: %v\", certificateFileFullPath, err)\n\t}\n\n\tif pemRaw, err = os.ReadFile(absFile); err != nil {\n\t\treturn nil, fmt.Errorf(\"can't read %s: %v\", certificateFileFullPath, err)\n\t}\n\treturn\n}\nfunc UserAgentFromEnv() string {\n\n\tuserAgentFromEnv := getEnvSettingWithBlankDefault(UserAgentSDKNameEnv)\n\tif userAgentFromEnv == \"\" {\n\t\tuserAgentFromEnv = getEnvSettingWithBlankDefault(UserAgentTerraformNameEnv)\n\t}\n\tif userAgentFromEnv == \"\" {\n\t\tuserAgentFromEnv = DefaultUserAgentBackendName\n\t}\n\n\treturn userAgentFromEnv\n}\n\n// OboTokenProvider interface that wraps information about auth tokens so the sdk client can make calls\n// on behalf of a different authorized user","sourceCodeStart":319,"sourceCodeEnd":355,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/backend/remote-state/oci/auth.go#L319-L355","documentation":"Returned by getCertificateFileBytes() when os.ReadFile fails after the path was successfully resolved to absolute. This is the actual file read failure — the file doesn't exist at the resolved path, is not readable, or is a directory.","triggerScenarios":"Any certificate file read for InstancePrincipalWithCerts where the file doesn't exist at the resolved absolute path, has restrictive permissions, or is otherwise unreadable.","commonSituations":"test_certificates_location points to wrong directory; certificate file was deleted or renamed; file permission is too restrictive; typo in the filename; this error wraps the underlying os.ReadFile error with %v for details.","solutions":["Check the wrapped %v error for the exact OS-level cause (no such file, permission denied, etc.).","Verify the file exists at the resolved absolute path: ls -la /full/resolved/path/ip_cert.pem.","Set test_certificates_location to the correct directory.","Fix file permissions if needed (chmod 644 or 600)."],"exampleFix":"// before\nexport test_certificates_location=/wrong/path\nterraform init\n// Error: can't read /wrong/path/ip_cert.pem: ...\n\n// after\nexport test_certificates_location=/home/user/test-certs\nls /home/user/test-certs/ip_cert.pem  # verify\nterraform init","handlingStrategy":"validation","validationCode":"func validateCertFilesReadable(certsDir string, files []string) error {\n    for _, f := range files {\n        p := filepath.Join(certsDir, f)\n        abs, _ := filepath.Abs(p)\n        if _, err := os.ReadFile(abs); err != nil {\n            return fmt.Errorf(\"cannot read %s: %w\", abs, err)\n        }\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"// Pre-validate all cert files:\nrequiredCerts := []string{\"ip_cert.pem\", \"ip_key.pem\", \"intermediate.pem\"}\nif err := validateCertFilesReadable(certsDir, requiredCerts); err != nil {\n    log.Fatal(err)\n}","preventionTips":["Pre-validate that all certificate files exist and are readable before terraform init.","Use absolute paths for test_certificates_location.","Check file permissions as part of CI pre-flight checks."],"tags":["oci","authentication","filesystem","certificates","instance-principal","io","terraform-backend"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}