{"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/c9def3e214014c1188faabfc4a5bde5095139765/internal/cloud/backend.go#L738-L774","documentation":"Returned in backend StateMgr at backend.go:756 when b.client.Projects.List fails with a non-ErrResourceNotFound error during project resolution for a configured project (project= or TF_CLOUD_PROJECT). Unlike 474, the raw API error is swallowed and only the generic message naming the project (%s) is reported. This blocks backend initialization for plan/apply.","triggerScenarios":"terraform plan/apply with a cloud backend that sets a project; the Projects.List lookup fails with a transport/permission/5xx error (404 is tolerated).","commonSituations":"Token lacks project-list permission; API outage; rate limiting; the configured project name is valid but the API is unreachable.","solutions":["Grant the token project-read permission in the organization.","Retry on transient API failures; verify HCP/TFE health.","Temporarily remove project scoping to confirm the token/org pair works, then re-add."],"exampleFix":"// before\ncloud { workspaces { project = \"platform\" name = \"dev\" } }\n\n// after: confirm access first without project scoping\ncloud { workspaces { name = \"dev\" } }\n# re-add project once token has project-read","handlingStrategy":"try-catch","validationCode":"// Confirm project-list permission before relying on it.\nif _, err := b.client.Projects.List(ctx, org, &tfe.ProjectListOptions{Name: project}); err != nil && !errors.Is(err, tfe.ErrResourceNotFound) {\n    return fmt.Errorf(\"token cannot list projects: %w\", err)\n}","typeGuard":"if errors.Is(err, tfe.ErrResourceNotFound) { /* tolerate */ } else { /* init failure */ }","tryCatchPattern":"projects, err := b.client.Projects.List(ctx, org, opts)\nif err != nil && !errors.Is(err, tfe.ErrResourceNotFound) {\n    return nil, fmt.Errorf(\"Attempted to find configured project %s but was unable to.\", project)\n}","preventionTips":["Grant project-read permission to the token's team.","Retry on transient API errors during backend initialization."],"tags":["terraform","cloud-backend","tfe-api","projects","permissions"],"analyzedSha":"c9def3e214014c1188faabfc4a5bde5095139765","analyzedAt":"2026-08-07T15:39:49.278Z","schemaVersion":2},"datasetVersion":"2026-08-07T21:17:07.882Z"}