integrations / integrations/terraform-provider-github

[BUG]: data.github_users does not resolve Enterprise Managed Users

Open
#3,644 1 comment 0 reactions 0 assignees View on GitHub
Status: Triage Type: Bug
Dominant language
Go
Stars
1.2k
Forks
1k
Avg merge
1d 14h
Merged PRs (30d)
8

Description

### Expected Behavior

The data source [github_users](https://registry.terraform.io/providers/integrations/github/latest/docs/data-sources/users) should handle Enterprise Managed Users (EMUs) just like [github_user](https://registry.terraform.io/providers/integrations/github/latest/docs/data-sources/user) does. Thus the following precondition should be met.

The issue is likely caused by data.github_users using the GraphQL API, whereas data.github_user uses the REST API.

```opentofu
data "github_users" "demo" {
usernames = ["Charlie-Smith_contoso", "contoso_admin"]
}

data "github_user" "demo" {
for_each = toset(["Charlie-Smith_contoso", "contoso_admin"])
username = each.value
}

resource "terraform_data" "demo" {
lifecycle {
precondition {
condition = toset(data.github_users.demo.logins) == toset([for u in data.github_user.demo : u.login])
error_message = "The two data sources returned different results."
}
}
}
```

### Actual Behavior

The precondition fails:

```

│ Error: Resource precondition failed

│ on main.tf line 11, in resource "terraform_data" "demo":
│ 11: condition = toset(data.github_users.demo.logins) == toset([for u in data.github_user.demo : u.login])
│ ├────────────────
│ │ data.github_user.demo is object with 2 attributes
│ │ data.github_users.demo.logins is empty list of string
│ ├────────────────
│ │ Diff:
│ │ [
│ │ + "Charlie-Smith_contoso",
│ │ + "contoso_admin",
│ │ ]

│ The two data sources returned different results.
```

### Terraform Version

Terraform v1.16.2
on linux_amd64
+ provider registry.terraform.io/integrations/github v6.13.0

### GitHub Installation Type

- [ ] GitHub.com (Free, Pro, or Team)
- [ ] GitHub Enterprise Server (on-premises)
- [ ] GitHub Enterprise Cloud with Personal Accounts (github.com)
- [x] GitHub Enterprise Cloud with Managed Users/EMU (github.com)
- [ ] GitHub Enterprise Cloud with Data Residency (*.ghe.com)
- [ ] I don't know

### Affected Resource(s)

- data.github_users

### Terraform Configuration Files

```hcl

```

### Steps to Reproduce

_No response_

### Debug Output

```shell

```

### Code of Conduct

- [x] I agree to follow this project's Code of Conduct

Contributor guide

Open the contributing guide

Research direction

Start at the data.github_users implementation and compare its GraphQL lookup with the REST-backed data.github_user behavior described in the issue. Reproduce the Enterprise Managed Users example, then verify that data.github_users returns the same logins as data.github_user for both listed usernames.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, graphql, terraform
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.