Skip to content

Commit

Permalink
updated clause
Browse files Browse the repository at this point in the history
  • Loading branch information
duedares-rvj committed Feb 13, 2025
1 parent fd67bfc commit cb1a4f2
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions internal/auth0/user/data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,17 @@ func readUserForDataSource(ctx context.Context, data *schema.ResourceData, meta
return diag.FromErr(err)
}

// The data-source retrieves the details about a user along with roles and permissions.
// The roles and permissions are slices.
// Hence, it is important that the search bottoms out to a single user.
// If multiple users are retrieved via Lucene Query, we prompt the user to add further filters.
if users.Length == 1 {
switch users.Length {
case 0:
return diag.Errorf("No users found. Note: if a user was just created/deleted, it takes some time for it to be indexed.")
case 1:
// The data-source retrieves the details about a user along with roles and permissions.
// The roles and permissions are slices.
// Hence, it is important that the search bottoms out to a single user.
// If multiple users are retrieved via Lucene Query, we prompt the user to add further filters.
user = users.Users[0]
data.SetId(users.Users[0].GetID())
} else {
default:
return diag.Errorf("Further improve the query to retrieve a single user from the query")
}
}
Expand Down

0 comments on commit cb1a4f2

Please sign in to comment.