{"record":{"id":"00d3aad9669e1c16","repo":"hashicorp/terraform","slug":"can-t-form-absolute-path-of-s-v","errorCode":null,"errorMessage":"can't form absolute path of %s: %v","messagePattern":"can't form absolute path of (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/backend/remote-state/oci/auth.go","lineNumber":333,"sourceCode":"func buildHttpClient() (httpClient *http.Client) {\n\thttpClient = &http.Client{\n\t\tTimeout: getDurationFromEnvVar(HTTPRequestTimeOut, DefaultRequestTimeout),\n\t\tTransport: &http.Transport{\n\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","sourceCodeStart":315,"sourceCodeEnd":351,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/backend/remote-state/oci/auth.go#L315-L351","documentation":"Returned by getCertificateFileBytes() when filepath.Abs() fails to convert the certificate file path to an absolute path. filepath.Abs combines the input with the current working directory; it can fail if the working directory cannot be determined (same root cause as os.Getwd() failures).","triggerScenarios":"Any certificate file read for InstancePrincipalWithCerts (ip_cert.pem, ip_key.pem, intermediate.pem, leaf_passphrase) where filepath.Abs cannot resolve the path to absolute — typically because the process's working directory is inaccessible or deleted.","commonSituations":"Process's working directory was removed; running in a container with an invalid cwd; restricted environment; this is a rare OS-level failure, not a typical configuration mistake.","solutions":["Use an absolute path for certificate files to avoid dependency on filepath.Abs resolution.","Ensure the terraform process runs from a valid, accessible directory.","Check container/process cwd configuration.","Set test_certificates_location to an absolute path."],"exampleFix":"// before\nexport test_certificates_location=./certs\n// relative path triggers filepath.Abs which can fail\n\n// after\nexport test_certificates_location=/home/user/certs\nterraform init","handlingStrategy":"validation","validationCode":"func validateWorkingDirAccessible() error {\n    wd, err := os.Getwd()\n    if err != nil {\n        return fmt.Errorf(\"cannot determine working directory: %w\", err)\n    }\n    if _, err := os.Stat(wd); err != nil {\n        return fmt.Errorf(\"working directory '%s' is not accessible: %w\", wd, err)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"// Pre-check before terraform init:\nif err := validateWorkingDirAccessible(); err != nil {\n    log.Printf(\"working dir issue: %v — switching to workspace dir\", err)\n    os.Chdir(workspaceDir)\n}","preventionTips":["Use absolute paths for certificate files to avoid filepath.Abs dependency.","Run terraform from a stable directory.","In CI, explicitly set the working directory."],"tags":["oci","authentication","filesystem","certificates","instance-principal","environment","terraform-backend"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}