{"record":{"id":"672829ec8d5a53f8","repo":"hashicorp/terraform","slug":"attempted-to-find-configured-project-s-but-was-un","errorCode":null,"errorMessage":"Attempted to find configured project %s but was unable to.","messagePattern":"Attempted to find configured project (.+?) but was unable to\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cloud/backend.go","lineNumber":756,"sourceCode":"\tworkspace, err := b.client.Workspaces.Read(context.Background(), b.Organization, name)\n\tif err != nil && err != tfe.ErrResourceNotFound {\n\t\treturn nil, diags.Append(fmt.Errorf(\"Failed to retrieve workspace %s: %v\", name, err))\n\t}\n\tif workspace != nil {\n\t\tremoteTFVersion = workspace.TerraformVersion\n\t}\n\n\tvar configuredProject *tfe.Project\n\n\t// Attempt to find project if configured\n\tif b.WorkspaceMapping.Project != \"\" {\n\t\tlistOpts := &tfe.ProjectListOptions{\n\t\t\tName: b.WorkspaceMapping.Project,\n\t\t}\n\t\tprojects, err := b.client.Projects.List(context.Background(), b.Organization, listOpts)\n\t\tif err != nil && err != tfe.ErrResourceNotFound {\n\t\t\t// This is a failure to make an API request, fail to initialize\n\t\t\treturn nil, diags.Append(fmt.Errorf(\"Attempted to find configured project %s but was unable to.\", b.WorkspaceMapping.Project))\n\t\t}\n\t\tfor _, p := range projects.Items {\n\t\t\tif p.Name == b.WorkspaceMapping.Project {\n\t\t\t\tconfiguredProject = p\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\n\t\tif configuredProject == nil {\n\t\t\t// We were able to read project, but were unable to find the configured project\n\t\t\t// This is not fatal as we may attempt to create the project if we need to create\n\t\t\t// the workspace\n\t\t\tlog.Printf(\"[TRACE] cloud: Attempted to find configured project %s but was unable to.\", b.WorkspaceMapping.Project)\n\t\t}\n\t}\n\n\tif err == tfe.ErrResourceNotFound {\n\t\t// Create workspace if it was not found","sourceCodeStart":738,"sourceCodeEnd":774,"githubUrl":"https://github.com/hashicorp/terraform/blob/d32a084675427f5ac3f7d2868578ef8b2c1dc525/internal/cloud/backend.go#L738-L774","documentation":"During StateMgr initialization, when a project is configured in the workspace mapping, the backend queries the TFE/HCP API for projects matching the name. If the Projects.List call fails with any error other than tfe.ErrResourceNotFound, this error is returned and state manager initialization fails. Note: if the project is simply not found (nil result), it is handled non-fatally (logged at line 769), but an actual API request failure is fatal.","triggerScenarios":"Calling b.client.Projects.List at backend.go:753 returns a non-nil, non-404 error. This occurs when the API request itself fails — authentication errors, permission denied, rate limiting, server errors, or network issues. The error message specifically says 'was unable to', indicating the request could not be completed, not that the project was absent.","commonSituations":"The API token lacks permissions to list projects. The TFE instance version predates the Projects API. Transient network errors during 'terraform init' or 'terraform plan'. Rate limiting from concurrent operations. The organization name is incorrect, causing an API-level error.","solutions":["Ensure the API token has read access to projects in the organization.","Verify the TFE/HCP Terraform instance supports the Projects API (TFE 202208-x or later).","Retry the operation if the error was transient.","If projects are not needed, remove the 'project' attribute from the workspaces block."],"exampleFix":"# before — project configured but API access fails\ncloud {\n  organization = \"my-org\"\n  workspaces {\n    tags    = [\"env:prod\"]\n    project = \"platform\"\n  }\n}\n\n# after — remove project if unsupported, or fix permissions\ncloud {\n  organization = \"my-org\"\n  workspaces {\n    tags = [\"env:prod\"]\n  }\n}\n# Alternatively, ensure token has project read perms and TFE supports Projects API","handlingStrategy":"retry","validationCode":"// Before StateMgr init, verify project API is accessible\nif b.WorkspaceMapping.Project != \"\" {\n    resp, err := b.client.Projects.List(ctx, b.Organization, listOpts)\n    if err != nil && err != tfe.ErrResourceNotFound {\n        return fmt.Errorf(\"projects API not accessible: %w\", err)\n    }\n    _ = resp\n}","typeGuard":null,"tryCatchPattern":"// Retry project listing during StateMgr init\nfor i := 0; i < 3; i++ {\n    projects, err := b.client.Projects.List(ctx, b.Organization, listOpts)\n    if err == nil || err == tfe.ErrResourceNotFound {\n        break\n    }\n    if i == 2 {\n        return nil, diags.Append(fmt.Errorf(\"Attempted to find configured project %s but was unable to.\", b.WorkspaceMapping.Project))\n    }\n    time.Sleep(time.Duration(1<<i) * time.Second)\n}","preventionTips":["Ensure the TFE/HCP Terraform instance supports the Projects API before using the project attribute.","Verify the API token has project list/read permissions.","Remove the project attribute if projects are not used in your organization.","Retry transient API errors with backoff."],"tags":["terraform","cloud-backend","project","state-manager","tfe-api","go"],"backgroundTag":null,"analyzedSha":"d32a084675427f5ac3f7d2868578ef8b2c1dc525","analyzedAt":"2026-08-11T18:43:52.779Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}