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] Future grants to database roles are re-applied all the time #182

Open
mlavaert opened this issue Dec 23, 2024 · 1 comment
Open

[BUG] Future grants to database roles are re-applied all the time #182

mlavaert opened this issue Dec 23, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@mlavaert
Copy link
Contributor

Something goes wrong fetching existing future grants to database roles. I've done a bit of debugging but failed to figure it out.

The problem starts here in data_provider.py in the fetch_future_grant function:

  grants = _filter_result(
      show_result,
      privilege=fqn.params["priv"],
      name=collection_str,
      grant_to=str(to_type),
      grantee_name=to,
  )

  if len(grants) == 0:
      return None
  elif len(grants) > 1:
      raise Exception(f"Found multiple future grants matching {fqn}")

str(to_type) will return DATABASE ROLE but the query in Snowflake uses DATABASE_ROLE in the result.
to uses the full FQN including the database name of the database role. Snowflake uses just the name of the database role.

@teej teej added the bug Something isn't working label Dec 23, 2024
@toadies
Copy link

toadies commented Jan 30, 2025

I ended up updating my code to the following so I can proceed with my project.

Additional issue: grantee_name != value
Upon inspection, snowflake's role table only returns the database role name and does not include the database qualifier.

While reviewing fetch_future_grants, I noticed the process is fetching future grants by the to value, so no reason to match by grantee_name again.

grants = _filter_result(
        show_result,
        privilege=fqn.params["priv"],
        name=collection_str,
        grant_to=str(to_type).replace(" ", "_"),
        # grantee_name=to,
    )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants