ITADN

SQL Lab returns "invalid username-password pair or user is disabled." but get_sqla_engine() and get_raw_connection() both work fine

#42123Openroyspeedy 创建于 2026-07-17
validation:requiredsqllabdata:connect:postgres
R
royspeedycommented
### Bug description ### Bug description SQL Lab query execution fails with error "invalid username-password pair or user is disabled." but I can prove that the database connection itself works perfectly fine. ### How to reproduce the bug 1. Create a PostgreSQL database connection in Superset 2. Test connection - SUCCESS 3. Browse database/schema - SUCCESS 4. Open SQL Lab, write `SELECT 1;`, click Run - FAILS with error ### Expected behavior Query should execute successfully since the database connection works. ### Actual behavior Error message: "invalid username-password pair or user is disabled." ### Proof that database connection works I tested directly in `superset shell`: ```python from superset import db from superset.models.core import Database row = db.session.query(Database).filter_by(id=1).first() # Test 1: get_sqla_engine() - SUCCESS with row.get_sqla_engine() as engine: result = engine.execute("SELECT 1").scalar() print(result) # Output: 1 # Test 2: get_raw_connection() - SUCCESS with row.get_raw_connection(catalog=None, schema=None, source="sql_lab") as conn: cur = conn.cursor() cur.execute("SELECT 1") print(cur.fetchall()) # Output: [(1,)] ``` ### Database configuration - Database name: SRS - SQLAlchemy URI: `postgresql+psycopg2://postgres:XXX@192.168.0.128:5432/booking` - Extra: `{"allows_virtual_table_explore":true}` - Impersonate user: False - Allow DML: False - Allow CTAS: False ### Pod logs superset.exceptions.SupersetErrorsException: [SupersetError( message='invalid username-password pair or user is disabled.', error_type=<SupersetErrorType.GENERIC_DB_ENGINE_ERROR>, level=<ErrorLevel.ERROR>, extra={'engine_name': 'PostgreSQL', 'issue_codes': [{'code': 1002, 'message': 'Issue 1002 - The database returned an unexpected error.'}]} )] Important: PostgreSQL server logs show NO connection attempts, which means the error is thrown inside Superset before reaching PostgreSQL. ### Troubleshooting steps already taken 1. ✅ Verified `get_sqla_engine()` works in superset shell 2. ✅ Verified `get_raw_connection()` works in superset shell 3. ✅ Checked PostgreSQL logs - no connection attempts 4. ✅ Set `SQLLAB_BACKEND_PERSISTENCE=false` - still fails 5. ✅ Database configuration looks normal (no impersonation, no DML, no CTAS) ### Environment - Superset version: (run `pip show apache-superset` or check the About page) - Kubernetes deployment - PostgreSQL 12+ (or your version) ### Additional context This appears to be a Superset internal error, not a database connection issue. The error message is misleading because: 1. Database connection works fine when tested directly 2. PostgreSQL never receives the connection attempt 3. The error seems to be thrown in the SQL Lab execute path before reaching the database Please help identify where in the SQL Lab execute flow this error is being thrown. ### Screenshots/recordings _No response_ ### Superset version master / latest-dev ### Python version 3.9 ### Node version 16 ### Browser Chrome ### Additional context _No response_ ### 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.
0 条评论