Skip to content

Commit

Permalink
Merge pull request #1110 from xuzhang3/main
Browse files Browse the repository at this point in the history
Bug fix `azuredevops_users` -  Fix user not found
  • Loading branch information
xuzhang3 committed Jul 24, 2024
2 parents 30abfbf + ebdd429 commit 90656af
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion azuredevops/internal/acceptancetests/data_users_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ data "azuredevops_users" "test" {
func hclDataUserAllSvc() string {
return `
data "azuredevops_users" "test" {
subject_types = ["svc"]
subject_types = ["aad"]
}`
}

Expand Down
8 changes: 8 additions & 0 deletions azuredevops/internal/service/graph/data_users.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,14 @@ func dataUsersRead(d *schema.ResourceData, m interface{}) error {
).
ToSlice(&descriptors)

if len(users) == 0 {
if principalName != "" {
return fmt.Errorf(" User not found. Principal Name: %s", principalName)
} else if originID != "" {
return fmt.Errorf(" User not found. Origin ID: %s", originID)
}
}

h := sha1.New()
if _, err := h.Write([]byte(strings.Join(descriptors, "-"))); err != nil {
return fmt.Errorf("Unable to compute hash for user descriptors: %v", err)
Expand Down

0 comments on commit 90656af

Please sign in to comment.