Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Error when using data source snowflake_users #2902

Closed
1 task
calleo opened this issue Jul 1, 2024 · 4 comments · Fixed by #2977
Closed
1 task

[Bug]: Error when using data source snowflake_users #2902

calleo opened this issue Jul 1, 2024 · 4 comments · Fixed by #2977
Labels
bug Used to mark issues with provider's incorrect behavior data_source:users Issue connected to the snowflake_users data source

Comments

@calleo
Copy link

calleo commented Jul 1, 2024

Terraform CLI Version

1.6.6

Terraform Provider Version

0.92.0

Terraform Configuration

data "snowflake_users" "all_users" {
  pattern = "%MATSMART%"
}

Category

category:data_source

Object type(s)

data_source:users

Expected Behavior

I expect the data source to return a list of users, since the there are users matching the pattern.

Actual Behavior

null is returned.

Steps to Reproduce

Snowflake version: 8.23.5

  1. Create a user with the name "[email protected]"
  2. Use the resource as specified above, it should return the user you just created

How much impact is this issue causing?

Medium

Logs

https://gist.github.com/calleo/9b37c61b37eb138c16518bbc19c50d86

Additional Information

Looks like a problem with parsing the output of SHOW USERS. I have tried executing the exact same SQL statement, with the same user and role, and can see that it actually returns users.

My initial thought was that the disabled column contained null values, but I can also see true/false.

Would you like to implement a fix?

  • Yeah, I'll take it 😎
@calleo calleo added the bug Used to mark issues with provider's incorrect behavior label Jul 1, 2024
@sfc-gh-jmichalak sfc-gh-jmichalak added the data_source:users Issue connected to the snowflake_users data source label Jul 2, 2024
@sfc-gh-jmichalak
Copy link
Collaborator

sfc-gh-jmichalak commented Jul 2, 2024

Hey @calleo . Thanks for reaching out to us.

The user datasource will be redesigned as part of https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/ROADMAP.md#preparing-essential-ga-objects-for-the-provider-v1. I will link this issue to https://github.com/Snowflake-Labs/terraform-provider-snowflake/blob/main/v1-preparations/ESSENTIAL_GA_OBJECTS.MD. As a workaround, you can use unsafe_execute with query parameter.

@sebasziegler
Copy link

sebasziegler commented Jul 4, 2024

I am having the same issue at the moment, this used to work up to one month ago from the date, I guess there were some changes on the API in Snowflake side.

In our case we are using the TF provider 0.89.0

Also seems like the reply from the api gives some fields as null while running SHOW USERS LIKE 'MY_USER' from the UI actually returns those fields as true/false

Screenshot 2024-07-04 at 10 46 01

sfc-gh-asawicki added a commit that referenced this issue Aug 28, 2024
Fix known user resource-connected issues:
- Change the sensitiveness of name and login_name (References: #2662
#2668)
- Handle "null" properly for the nullable bool text attributes in user
(References: #2817)
- Fix diff suppression for default_x in user resource (References:
#2836)
- Update the migration guide (References #2938 #2942)
- Fix incorrect state after failed to alter (References #2970)
- Confirm the problem with the computed disabled attribute (References
#1572)
- Confirm that the problem with the null-out password was already solved
(References #1535)
- Add TODO to handle days to expiry in user (References #1155)

The next 2 PRs will contain:
- adjusting user resource to our rework conventions (also adding
additional fields and handling #1155 and #1572)
- adjusting user datasource (will handle #2902)

User rework will not include handling new types of users (service,
legacy service); this will be done a bit later.
sfc-gh-asawicki added a commit that referenced this issue Sep 3, 2024
User datasource reworked and aligned with our V1 guidelines,
additionally:
- added a way to reuse show_output and parameters assertions in the
datasource tests
- added init to add Sensitive to certain fields in generated and not
generated output schemas
- added describe output to user (manually like for a few other objects)

References: #2902
sfc-gh-jcieslak pushed a commit that referenced this issue Sep 4, 2024
🤖 I have created a release *beep* *boop*
---


##
[0.95.0](v0.94.1...v0.95.0)
(2024-09-04)


### 🎉 **What's new:**

* Add change_tracking, row access policy and aggregation policy to views
([#2988](#2988))
([1f88bb1](1f88bb1))
* Add fully_qualified_name to all resources
([#2990](#2990))
([1b0462f](1b0462f))
* Add identifier parsers
([#2957](#2957))
([824ec52](824ec52))
* Add identifier with arguments
([#2979](#2979))
([00ae1c5](00ae1c5))
* Add timeouts block to cortex
([#3004](#3004))
([34d764b](34d764b))
* Add user parameters to resource
([#2968](#2968))
([f4ae380](f4ae380))
* Conclude user rework
([#3036](#3036))
([23e4625](23e4625))
* database role v1 readiness
([#3014](#3014))
([c4db255](c4db255))
* Identifier with arguments for procedure and external function
([#2987](#2987))
([f13cc5c](f13cc5c))
* Rework user resource
([#3026](#3026))
([bde2638](bde2638)),
closes
[#1572](#1572)
* Rework users datasource
([#3030](#3030))
([751239b](751239b)),
closes
[#2902](#2902)
* Upgrade view sdk
([#2969](#2969))
([ef2d50a](ef2d50a))
* View rework part 2
([#3021](#3021))
([e05377d](e05377d))
* View rework part 3
([#3023](#3023))
([195b41c](195b41c))


### 🔧 **Misc**

* Add annotation about fully_qualified_name and fix handling granteeName
([#3009](#3009))
([94e6345](94e6345))
* Apply identifier conventions
([#2996](#2996))
([5cbea84](5cbea84))
* apply identifier conventions to grants
([#3008](#3008))
([d7780ae](d7780ae))
* Clean collection utils
([#3028](#3028))
([426ddb1](426ddb1))
* Clean old assertions
([#3029](#3029))
([ad657eb](ad657eb))
* Conclude identifiers rework
([#3011](#3011))
([c1b53f3](c1b53f3))
* Improve user test and add manual test for user default database and
role
([#3035](#3035))
([6cb0b4e](6cb0b4e))
* Use new identifier with arguments in function, external function and
procedure grants
([#3002](#3002))
([5053f8b](5053f8b))
* User improvements
([#3034](#3034))
([65b64d7](65b64d7))


### 🐛 **Bug fixes:**

* database tests and introduce a new parameter
([#2981](#2981))
([3bae7f6](3bae7f6))
* Fix custom diffs for fields with diff supression
([#3032](#3032))
([2499602](2499602))
* Fix default secondary roles after BCR 2024_07
([#3040](#3040))
([2ca465a](2ca465a)),
closes
[#3038](#3038)
* Fix issues 2972 and 3007
([#3020](#3020))
([1772387](1772387))
* Fix known user resource issues
([#3013](#3013))
([a5dfeac](a5dfeac))
* identifier issues
([#2998](#2998))
([6fb76b7](6fb76b7))
* minor issues
([#3027](#3027))
([467b06e](467b06e)),
closes
[#3015](#3015)
[#2807](#2807)
[#3025](#3025)
* Nuke users
([#2971](#2971))
([0d90cc9](0d90cc9))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: snowflake-release-please[bot] <105954990+snowflake-release-please[bot]@users.noreply.github.com>
@sfc-gh-asawicki
Copy link
Collaborator

Hey @calleo.
We have just released v0.95.0 of the provider. It contains a reworked snowflake_users data source. Please consult the migration guide.

@sfc-gh-asawicki
Copy link
Collaborator

Closing the issue due to inactivity. Please create a new one if the issue persists in the newest version of the provider.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Used to mark issues with provider's incorrect behavior data_source:users Issue connected to the snowflake_users data source
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants