Repository navigation
Description
Describe the bug
A JOIN with no ON clause crashes the process with an unrecovered nil pointer dereference during plan building (early AST analysis), instead of returning a parser or planner error. No provider call is made and no credentials are needed to trigger it.
To Reproduce
Using the homebrew provider (no auth required):
stackql exec "REGISTRY PULL homebrew"
stackql exec "SELECT a.name FROM homebrew.formula.formula a JOIN homebrew.formula.formula b WHERE a.formula_name = 'stackql' AND b.formula_name = 'jq'"Also reproduces with no WHERE clause, and across providers, for example:
SELECT 1 FROM databricks_account.provisioning.workspaces w JOIN databricks_account.iam.account_users u;Output:
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x18 pc=0x7ff7234d5de4]
goroutine 1 [running]:
github.com/stackql/stackql/internal/stackql/astanalysis/earlyanalysis.(*indirectExpandAstVisitor).Visit(0xc000306600, {0x7ff72435cec0, 0xc000bbfda0})
D:/a/stackql/stackql/internal/stackql/astanalysis/earlyanalysis/ast_expand.go:996 +0x3a64
github.com/stackql/stackql-parser/go/vt/sqlparser.JoinCondition.Accept(...)
C:/Users/runneradmin/go/pkg/mod/github.com/stackql/stackql-parser@v0.0.16-alpha02/go/vt/sqlparser/external_visitor.go:54
github.com/stackql/stackql/internal/stackql/astanalysis/earlyanalysis.(*indirectExpandAstVisitor).Visit(0xc000306600, {0x7ff72435ce98, 0xc000409260})
D:/a/stackql/stackql/internal/stackql/astanalysis/earlyanalysis/ast_expand.go:1016 +0x416c
github.com/stackql/stackql-parser/go/vt/sqlparser.(*JoinTableExpr).Accept(0xc00047a660?, {0x7ff724354fa0?, 0xc000306600?})
C:/Users/runneradmin/go/pkg/mod/github.com/stackql/stackql-parser@v0.0.16-alpha02/go/vt/sqlparser/external_visitor.go:55 +0x2e
github.com/stackql/stackql/internal/stackql/astanalysis/earlyanalysis.(*indirectExpandAstVisitor).Visit(0xc000306600, {0x7ff72435c6a0, 0xc000402c90})
D:/a/stackql/stackql/internal/stackql/astanalysis/earlyanalysis/ast_expand.go:837 +0x8f57
github.com/stackql/stackql-parser/go/vt/sqlparser.TableExprs.Accept(...)
C:/Users/runneradmin/go/pkg/mod/github.com/stackql/stackql-parser@v0.0.16-alpha02/go/vt/sqlparser/external_visitor.go:98
github.com/stackql/stackql/internal/stackql/astanalysis/earlyanalysis.(*indirectExpandAstVisitor).Visit(0xc000306600, {0x7ff72435cad8, 0xc000306540})
D:/a/stackql/stackql/internal/stackql/astanalysis/earlyanalysis/ast_expand.go:289 +0xa63c
github.com/stackql/stackql/internal/stackql/astanalysis/earlyanalysis.(*indirectExpandAstVisitor).Analyze(0xc000306600)
D:/a/stackql/stackql/internal/stackql/astanalysis/earlyanalysis/ast_expand.go:239 +0x4e
github.com/stackql/stackql/internal/stackql/astanalysis/earlyanalysis.(*standardInitialPasses).initialPasses(...)
D:/a/stackql/stackql/internal/stackql/astanalysis/earlyanalysis/first_passes.go:301 +0x776
github.com/stackql/stackql/internal/stackql/astanalysis/earlyanalysis.(*standardInitialPasses).Analyze(...)
D:/a/stackql/stackql/internal/stackql/astanalysis/earlyanalysis/first_passes.go:178 +0x31
github.com/stackql/stackql/internal/stackql/planbuilder.(*standardPlanBuilder).BuildPlanFromContext(0xc0002fcdb8, {0x7ff7243d92a0, 0xc00046e608})
D:/a/stackql/stackql/internal/stackql/planbuilder/entrypoint.go:140 +0xaf1
github.com/stackql/stackql/internal/stackql/querysubmit.(*basicQuerySubmitter).PrepareQuery(0xc00035b0e0, {0x7ff7243d92a0, 0xc00046e608})
D:/a/stackql/stackql/internal/stackql/querysubmit/querysubmit.go:87 +0xa5
...
Controls on the same resources that do not panic:
- comma join:
FROM homebrew.formula.formula a, homebrew.formula.formula b WHERE ... - explicit condition:
FROM homebrew.formula.formula a JOIN homebrew.formula.formula b ON 1 = 1 WHERE ...
Expected behavior
Either treat JOIN without ON as a cross join (as SQLite does), or return a clean error such as JOIN requires an ON clause. The process should not crash. In stackql shell or stackql srv (and the MCP server) an unrecovered panic in plan building takes down the session.
The top frame (ast_expand.go:996, visiting sqlparser.JoinCondition) suggests the visitor dereferences JoinCondition.On without a nil check when the condition is empty.
Environment
- stackql v0.12.718 Windows (0dba3cf), BuildDate 2026-09-22T03:05:44Z
- Windows 11 Pro 10.0.26200
- Providers: homebrew v25.01.00292, databricks_account v26.07.00430, databricks_workspace v26.07.00430
Additional context
Hit while trying to pass deployment_name (a server URL variable on databricks_workspace) from databricks_account.provisioning.workspaces into databricks_workspace.iam.current_user by putting the join condition in WHERE instead of ON.
Activity