Skip to content

【6.0.0-RC2】Formatting the SQL in the "View Query" pop-up doesn't work #35682

Closed

Description

@saghatelian

Bug description

The "original/formatted" toggle in the "View Query" pop-up doesn't work. It's stuck on "original". Clicking on the toggle gives an error (below) in Chrome console.

Note that it was working on "6.0.0rc1".

The error

9209.241e1adccfe51fea866f.entry.js:2  POST https://[DOMAIN-HIDDEN]/api/v1/sqllab/format_sql/ 400 (Bad Request)
n @ 9209.241e1adccfe51fea866f.entry.js:2
(anonymous) @ 9209.241e1adccfe51fea866f.entry.js:2
(anonymous) @ 9209.241e1adccfe51fea866f.entry.js:2
(anonymous) @ 2269.593775801f9ed22f060f.entry.js:1
u @ 2269.593775801f9ed22f060f.entry.js:1
request @ 2269.593775801f9ed22f060f.entry.js:1
await in request
post @ 2269.593775801f9ed22f060f.entry.js:1
post @ 2269.593775801f9ed22f060f.entry.js:1
(anonymous) @ 8fe7e097f8a517870d61.chunk.js:412
await in (anonymous)
onChange @ vendors.077cc2e3066bd62c36ac.entry.js:2
P @ 2483.ff4341ca7d28268597ab.entry.js:1
onClick @ 2483.ff4341ca7d28268597ab.entry.js:1
De @ vendors.077cc2e3066bd62c36ac.entry.js:2
Ue @ vendors.077cc2e3066bd62c36ac.entry.js:2
(anonymous) @ vendors.077cc2e3066bd62c36ac.entry.js:2
Or @ vendors.077cc2e3066bd62c36ac.entry.js:2
Er @ vendors.077cc2e3066bd62c36ac.entry.js:2
(anonymous) @ vendors.077cc2e3066bd62c36ac.entry.js:2
Re @ vendors.077cc2e3066bd62c36ac.entry.js:2
(anonymous) @ vendors.077cc2e3066bd62c36ac.entry.js:2
Pr @ vendors.077cc2e3066bd62c36ac.entry.js:2
Zt @ vendors.077cc2e3066bd62c36ac.entry.js:2
Qt @ vendors.077cc2e3066bd62c36ac.entry.js:2
t.unstable_runWithPriority @ 9209.241e1adccfe51fea866f.entry.js:2
Go @ vendors.077cc2e3066bd62c36ac.entry.js:2
Ie @ vendors.077cc2e3066bd62c36ac.entry.js:2
Kt @ vendors.077cc2e3066bd62c36ac.entry.js:2

Screenshots/recordings

Superset version

master / latest-dev

Python version

Not applicable

Node version

Not applicable

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.

Activity

  1. dosubot commented on Oct 16, 2025

    @dosubot

    This looks like a regression introduced between 6.0.0-RC1 and 6.0.0-RC2. The SQL formatting toggle in the "View Query" pop-up sends a POST request to /api/v1/sqllab/format_sql with a JSON payload containing the SQL string and the database engine. The backend strictly validates this payload and expects a non-empty sql field (string) and, optionally, an engine field (string or null) reference.

    Recent changes to SQL formatting logic and input validation (notably in PRs #30578 and #30350) may have made the backend less tolerant of missing or malformed fields, or changed how the frontend retrieves the engine value reference. If the frontend is sending an undefined or invalid engine, or if the sql field is empty or missing, the backend will return a 400 error.

    To troubleshoot, check the network request payload in your browser's dev tools and confirm both sql and engine are present and valid. If engine is undefined or the SQL is empty, that's likely the cause. This regression is likely due to stricter validation or a frontend change in how the engine is fetched from the dataset metadata.

    To reply, just mention @dosu.


    How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

  2. added
    sqllabNamespace | Anything related to the SQL Lab
    on Oct 16, 2025
  3. saghatelian commented on Oct 16, 2025

    @saghatelian
    ContributorAuthor

    Following the steps suggested by @dosu , here are the details of the request:

    Request URL: /api/v1/sqllab/format_sql/

    Payload:

    {
        "sql": "SELECT COUNT(client_id) AS `Signups` \nFROM `dataform_intermediate.clients_extended` \nWHERE `signup_date` >= CAST('2024-10-16T14:24:19.000000' AS TIMESTAMP) AND `signup_date` < CAST('2025-10-17T14:24:19.000000' AS TIMESTAMP)\n LIMIT 50000;",
        "engine": {
            "backend": "bigquery"
        }
    }
    

    Response:

    {
      "message": {
        "engine": [
          "Not a valid string."
        ]
      }
    }
    

    Seems like the error is because the engine is a JSON object {"backend":"bigquery"}, not a string.

  4. dosubot commented on Oct 16, 2025

    @dosubot

    The 400 error happens because the backend expects the engine field to be a string (like "bigquery"), not an object. The correct payload should look like:

    {
      "sql": "SELECT ...",
      "engine": "bigquery"
    }

    This is enforced by the backend schema and confirmed in the frontend code, which should send engine as a string, not as { "backend": "bigquery" } (reference, backend schema). The regression likely comes from a recent frontend change that started passing the whole backend object instead of just the string. Updating the frontend to send only the backend string should resolve the issue.

    To reply, just mention @dosu.


    How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

  5. added a commit that references this issue on Oct 30, 2025
    c93810f
  6. self-assigned this
    on Oct 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

sqllabNamespace | Anything related to the SQL Labvalidation:requiredA committer should validate the issue

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions