{"record":{"id":"4e8727f96059bd41","repo":"hashicorp/terraform","slug":"failed-to-get-absolute-path-of-the-configuration-d","errorCode":null,"errorMessage":"Failed to get absolute path of the configuration directory: %v","messagePattern":"Failed to get absolute path of the configuration directory: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cloud/test.go","lineNumber":129,"sourceCode":"\nfunc (runner *TestSuiteRunner) Stop() {\n\trunner.Stopped = true\n}\n\nfunc (runner *TestSuiteRunner) IsStopped() bool {\n\treturn runner.Stopped\n}\n\nfunc (runner *TestSuiteRunner) Cancel() {\n\trunner.Cancelled = true\n}\n\nfunc (runner *TestSuiteRunner) Test(_ bool) (moduletest.Status, tfdiags.Diagnostics) {\n\tvar diags tfdiags.Diagnostics\n\n\tconfigDirectory, err := filepath.Abs(runner.ConfigDirectory)\n\tif err != nil {\n\t\tdiags = diags.Append(fmt.Errorf(\"Failed to get absolute path of the configuration directory: %v\", err))\n\t\treturn moduletest.Error, diags\n\t}\n\n\tvariables, variableDiags := ParseCloudRunTestVariables(runner.GlobalVariables)\n\tdiags = diags.Append(variableDiags)\n\tif variableDiags.HasErrors() {\n\t\t// Stop early if we couldn't parse the global variables.\n\t\treturn moduletest.Error, diags\n\t}\n\n\taddr, err := tfaddr.ParseModuleSource(runner.Source)\n\tif err != nil {\n\t\tif parserError, ok := err.(*tfaddr.ParserError); ok {\n\t\t\tdiags = diags.Append(tfdiags.AttributeValue(\n\t\t\t\ttfdiags.Error,\n\t\t\t\tparserError.Summary,\n\t\t\t\tparserError.Detail,\n\t\t\t\tcty.Path{cty.GetAttrStep{Name: \"source\"}}))","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/cloud/test.go#L111-L147","documentation":"Thrown by TestSuiteRunner.Test when filepath.Abs fails to resolve the ConfigDirectory to an absolute path. filepath.Abs fails only when the OS cannot determine the current working directory (os.Getwd returns an error), typically because the process's working directory was deleted from underneath it. This is an environment/process-state error, not a configuration error.","triggerScenarios":"The process's current working directory was deleted or renamed while the test runner was initializing; the ConfigDirectory path is empty and Getwd fails; running terraform test from within a directory that another process removed; container/CI environment where the build workspace was cleaned mid-run.","commonSituations":"CI pipeline that cleans the workspace in a parallel step while terraform test is starting; a script that deletes and recreates the working directory; running in a ephemeral container whose mount was removed; very rare under normal interactive use.","solutions":["Ensure the working directory exists and is accessible when terraform test is invoked (do not delete it in parallel steps)","If ConfigDirectory is relative, ensure the process CWD is valid, or pass an absolute path","Re-run terraform test from a stable, existing directory","In CI, verify the checkout/workspace step completes before the test step starts and is not cleaned concurrently"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before invoking TestSuiteRunner.Test, verify the working directory exists:\nif wd, err := os.Getwd(); err != nil {\n    return fmt.Errorf(\"working directory is inaccessible, cannot resolve ConfigDirectory: %w\", err)\n} else {\n    absConfigDir := filepath.Join(wd, runner.ConfigDirectory)\n    if _, err := os.Stat(absConfigDir); err != nil {\n        return fmt.Errorf(\"config directory %s does not exist: %w\", absConfigDir, err)\n    }\n}","typeGuard":null,"tryCatchPattern":"// This is a fatal diagnostics error from Test(); catch at the caller:\nstatus, diags := runner.Test(false)\nfor _, d := range diags {\n    if strings.Contains(d.Description().Summary, \"absolute path\") {\n        // environment issue — CWD was deleted; restart from a valid directory\n        return fmt.Errorf(\"working directory issue during test: %s\", d.Description().Summary)\n    }\n}","preventionTips":["Never delete or rename the process working directory while terraform test is running","In CI, ensure the checkout/workspace is not cleaned by a concurrent step during the test phase","Pass an absolute ConfigDirectory to TestSuiteRunner to reduce dependence on CWD stability"],"tags":["test","filesystem","path","environment","terraform"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}