fix(cubejs): match checkSqlAuth signature to Cube.js v1.6#41
Merged
Conversation
Cube.js v1.6 invokes checkSqlAuth as (request, user, password) — three
positional args — see
@cubejs-backend/api-gateway/dist/src/sql-server.js:291,105.
Our implementation declared (_, user) and did:
password = typeof user === "string" ? user : user?.password
username = typeof user === "string" ? _ : user?.username
With the v1.6 wire server, user arrives as a plain string (the Postgres
username), so the code took the username as the password AND used the
request metadata object as the username. findSqlCredentials then
received the {protocol, method, apiType} object, and Hasura rejected
the query with:
parsing Text failed, expected String, but encountered Object
path: $.selectionSet.sql_credentials.args.where.username._eq
Every SQL API login failed before any password comparison ran
(reproduced via `psql -U <valid> -h <cubejs>` → 28P01).
Fix: match the documented v1.6 signature and keep a defensive branch
for the legacy object-shape call. Also reject non-string username
early so the Hasura GraphQL layer cannot receive a non-string variable.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
akshaykumar2505
approved these changes
Apr 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
checkSqlAuthcallback signature — Cube.js v1.6 passes(request, user, password)as three positional args; our code expected(_, user)and treated the username string as the password.Root cause
@cubejs-backend/api-gateway/dist/src/sql-server.js:291,105wraps the callback and always calls it with three positional args. When a Postgres client connects (e.g.psql -U e0m19ghdz9), Cube hands us:The existing code:
With
userbeing a string, this assigned the username string topasswordand the request object tousername.findSqlCredentialsthen called Hasura with an object variable:Every SQL login failed before the password was ever compared. Reproduced with
psql -h <cubejs> -p 15432 -U <valid> -d db→28P01 FATAL: password authentication failed.Fix
(request, userArg, passwordArg).{ username, password }) to not break anyone still on the old path.Incorrect user name or passwordrather than a 503 with a GraphQL parse error.Test plan
data/synmetrix/overlays/dev/kustomization.yamlto the new tagpsql -h dbx.fraios.dev -p 15432 -U <valid_sql_user> -d dbauthenticatespsql -U <datasource_id> -d dbwith a FraiOS JWT inPGPASSWORD)28P01🤖 Generated with Claude Code