Skip to content

Panic (nil pointer) on EXEC with @@json for methods with schema-less response columns #726

Closed

Description

@jeffreyaven

Summary

EXEC <resource>.<method> @@json = '...' panics with a nil pointer dereference during plan building for methods whose response tabulation yields a column with no resolved schema. No HTTP call is made; the process crashes.

Root cause parent: stackql/any-sdk#130 (newWrappedSchemaFromAnySdkSchema wraps a nil inner schema, producing a non-nil wrapper that defeats nil checks).

Observed with stackql v0.10.605, clickhouse provider v26.08.00442.

Repro

EXEC clickhouse.services.services.update_password
  @serviceId = '<uuid>'
  @@json = '{"newPasswordHash": "x", "newDoubleSha1Hash": "y"}';
panic: runtime error: invalid memory address or nil pointer dereference
github.com/stackql/any-sdk/public/formulation.(*wrappedSchema).GetType(...)
	wrappers.go:1378
github.com/stackql/stackql/internal/stackql/drm.(*staticDRMConfig).GenerateSelectDML(...)
	internal/stackql/drm/drm_cfg.go:725
github.com/stackql/stackql/internal/stackql/primitivegenerator.(*standardPrimitiveGenerator).assembleUnarySelectionBuilder(...)
	unary_selection.go:118
... AnalyzeUnaryExec -> analyzeExec -> AnalyzeStatement -> handleExec

Analysis

GenerateSelectDML guards with if col.GetSchema() != nil, but the value returned is a non-nil *formulation.wrappedSchema wrapping a nil anysdk.Schema, so the guard passes and GetType() dereferences nil (drm_cfg.go:723-725).

The method's 200 response is a plain object (status, requestId, result with one string property); one of the tabulated columns resolves no schema.

Suggested resolution

  • Primary: fix the wrapper factory in any-sdk (parent issue) so nil stays nil.
  • Defensive: drm_cfg.go already has an else-branch for schema-less columns (falls back on col.GetVal()); with the wrapper fixed, that branch would be taken instead of panicking. Optionally harden the guard to tolerate typed-nil wrappers.
  • A plan-builder panic should be recoverable per statement rather than crashing the process (affects server mode too).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions