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

Error with chart filters after applying RLS for dataset on PostgreSQL - column values are not available for preview #32394

Open
3 tasks done
propellerjet opened this issue Feb 26, 2025 · 1 comment · May be fixed by #32406
Open
3 tasks done
Labels
authentication:row-level-security Related to Row Level Security data:connect:postgres Related to Postgres

Comments

@propellerjet
Copy link

propellerjet commented Feb 26, 2025

Bug description

How to reproduce the bug

  1. Add RLS rule for dataset on Postgresql
    Image

  2. Create chart using this dataset

  3. Try to apply filter on the chart

As you can see on screeshot, no values are loaded for this column
Image

error:
Image

error in logs "ERROR:flask_appbuilder.api:dict is not a sequence"

It is possible to type values manually and it will work
Image

Dashboard filters also work correctly and load all available values.

Screenshots/recordings

No response

Superset version

4.1.1

Python version

3.9

Node version

I don't know

Browser

Chrome

Additional context

We face such error only with datasets on Postgresql

full log
213:ERROR:flask_appbuilder.api:dict is not a sequence

Traceback (most recent call last):

File "/app/venv/lib64/python3.9/site-packages/flask_appbuilder/api/init.py", line 111, in wraps

return f(self, *args, **kwargs)

File "/app/superset/views/base_api.py", line 119, in wraps

duration, response = time_function(f, self, *args, **kwargs)

File "/app/superset/utils/core.py", line 1364, in time_function

response = func(*args, **kwargs)

File "/app/superset/utils/log.py", line 303, in wrapper

value = f(*args, **kwargs)

File "/app/superset/datasource/api.py", line 120, in get_column_values

payload = datasource.values_for_column(

File "/app/superset/models/helpers.py", line 1372, in values_for_column

df = pd.read_sql_query(sql=sql, con=engine)

File "/app/venv/lib64/python3.9/site-packages/pandas/io/sql.py", line 469, in read_sql_query

return pandas_sql.read_query(

File "/app/venv/lib64/python3.9/site-packages/pandas/io/sql.py", line 1738, in read_query

result = self.execute(sql, params)

File "/app/venv/lib64/python3.9/site-packages/pandas/io/sql.py", line 1562, in execute

return self.con.exec_driver_sql(sql, *args)

File "/app/venv/lib64/python3.9/site-packages/sqlalchemy/engine/base.py", line 1770, in exec_driver_sql

return self._exec_driver_sql(

File "/app/venv/lib64/python3.9/site-packages/sqlalchemy/engine/base.py", line 1674, in _exec_driver_sql

ret = self._execute_context(

File "/app/venv/lib64/python3.9/site-packages/sqlalchemy/engine/base.py", line 1953, in _execute_context

self._handle_dbapi_exception(

File "/app/venv/lib64/python3.9/site-packages/sqlalchemy/engine/base.py", line 2138, in _handle_dbapi_exception

util.raise_(exc_info[1], with_traceback=exc_info[2])

File "/app/venv/lib64/python3.9/site-packages/sqlalchemy/util/compat.py", line 211, in raise_

raise exception

File "/app/venv/lib64/python3.9/site-packages/sqlalchemy/engine/base.py", line 1910, in _execute_context

self.dialect.do_execute(

File "/app/venv/lib64/python3.9/site-packages/sqlalchemy/engine/default.py", line 736, in do_execute

cursor.execute(statement, parameters)

TypeError: dict is not a sequence

Checklist

  • I have searched Superset docs and Slack and didn't find a solution to my problem.
  • I have searched the GitHub issue tracker and didn't find a similar bug report.
  • I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.
Copy link

dosubot bot commented Feb 26, 2025

The error "dict is not a sequence" typically occurs when a dictionary is passed to a function that expects a sequence (like a list or tuple). In the context of Superset, this error is happening in the pandas.io.sql module when executing SQL queries, specifically in the read_sql_query function.

Here are some steps you can take to troubleshoot and potentially resolve this issue:

  1. Check SQL Parameters: Ensure that the SQL query being executed does not have any dictionary objects where a sequence is expected. This might involve checking how parameters are being passed to the query.

  2. Review RLS Filters: Since the issue arises after applying Row Level Security (RLS) rules, verify that the RLS clauses are correctly formatted and do not inadvertently introduce dictionary objects into the query parameters.

  3. Inspect the values_for_column Function: This function constructs and executes the SQL query. Ensure that the parameters passed to pd.read_sql_query are correctly formatted. The sql and con arguments should be a valid SQL string and a SQLAlchemy connection object, respectively.

  4. Debugging: Add logging or print statements before the pd.read_sql_query call to inspect the sql and any parameters being passed. This can help identify if a dictionary is mistakenly being used.

  5. PostgreSQL Specifics: Since the issue is specific to PostgreSQL, ensure that any PostgreSQL-specific configurations or extensions are compatible with the RLS setup and the SQLAlchemy version in use.

If these steps do not resolve the issue, consider isolating the problem by creating a minimal example that reproduces the error, which can help in further debugging or seeking assistance.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

@dosubot dosubot bot added authentication:row-level-security Related to Row Level Security data:connect:postgres Related to Postgres labels Feb 26, 2025
@propellerjet propellerjet changed the title Error with chart filters after applying RLS for dataset on PosgreSQL - column values are not available for preview Error with chart filters after applying RLS for dataset on PostgreSQL - column values are not available for preview Feb 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
authentication:row-level-security Related to Row Level Security data:connect:postgres Related to Postgres
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant