Skip to content

SQL Lab Fails to Save Tab State — Incorrect database_id sent as string instead of integer #33935

@codewithz

Description

@codewithz

Bug description

We're encountering a repeated failure in SQL Lab when trying to save tab state. The backend logs reveal that database_id is being sent as a string ("postgresql-examples-1") instead of the expected integer ID, which results in an insert failure.

Connect to Superset using Docker (latest stable or master version).

Add a PostgreSQL database with name or UUID like postgresql-examples-1.

Go to SQL Lab → SQL Editor.

Create a new tab and attempt to write a simple query.

Observe the failure when Superset tries to persist the tab state.

ERROR: invalid input syntax for type integer: "postgresql-examples-1" STATEMENT: INSERT INTO tab_state (...) VALUES (..., 'postgresql-examples-1', ...)

🛠️ Environment Info:
Superset version: latest (or specify e.g., 3.0.1)

Deployment: Docker (docker-compose-non-dev.yml)

Database Backend: PostgreSQL 16

Browser: Chrome 137

OS: Linux (multiple OS tested)

Reproducible: Yes (across multiple machines and OS setups)

📎 Additional Context:
The issue seems related to SQL Lab's tab state API (POST /tabstateview/).

Appears to break compatibility in environments with example DBs or custom database names.

🙏 Request:
Please validate whether the frontend is passing the correct database_id, and consider adding input validation or type coercion on the backend to avoid this type mismatch.

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.

Metadata

Metadata

Assignees

Labels

sqllabNamespace | Anything related to the SQL Lab

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions