{"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/c9def3e214014c1188faabfc4a5bde5095139765/internal/cloud/test.go#L111-L147","documentation":"At the start of TestSuiteRunner.Test, filepath.Abs(runner.ConfigDirectory) resolves the configuration directory to an absolute path. This wraps a failure of that call.","triggerScenarios":"filepath.Abs fails when the process's current working directory cannot be determined, e.g. the cwd was deleted or renamed underneath the process.","commonSituations":"Running terraform test from a directory that was removed or renamed while the process ran, or unusual filesystem/permission state.","solutions":["Re-run from a valid, existing directory.","Ensure the shell's current working directory still exists.","Pass an absolute configuration directory path to the runner."],"exampleFix":"// before: runner.ConfigDirectory = \".\" while cwd was deleted -> abs path fails\n// after: pass an absolute, existing path\nrunner.ConfigDirectory = \"/home/user/my-module\"","handlingStrategy":"validation","validationCode":"// Validate the config directory exists and is resolvable before running tests\nabs, err := filepath.Abs(runner.ConfigDirectory)\nif err != nil {\n    return fmt.Errorf(\"cannot resolve config directory: %w\", err)\n}\nif info, err := os.Stat(abs); err != nil || !info.IsDir() {\n    return fmt.Errorf(\"config directory does not exist: %s\", abs)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run terraform test from an existing directory","Pass an absolute config directory path","Avoid renaming/removing the cwd while the process runs"],"tags":["filesystem","path","test-runner","environment"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T20:17:04.800Z"}