plandex-ai/plandex · error

unsupported data type: %T

Error message

unsupported data type: %T

What it means

ExtraAuthVars implements sql.Scanner; Scan only understands []byte and string column values. When the database driver hands the scanner any other Go type, this error is returned. It is a data-format mismatch between what the DB/driver produces and what this custom JSON type accepts.

Source

Thrown at app/server/db/data_models.go:476

		CreatedAt: &model.CreatedAt,
		UpdatedAt: &model.UpdatedAt,
	}
}

type ExtraAuthVars []shared.ModelProviderExtraAuthVars

func (e *ExtraAuthVars) Scan(src interface{}) error {
	if src == nil {
		return nil
	}

	switch s := src.(type) {
	case []byte:
		return json.Unmarshal(s, e)
	case string:
		return json.Unmarshal([]byte(s), e)
	default:
		return fmt.Errorf("unsupported data type: %T", src)
	}
}

func (e ExtraAuthVars) Value() (driver.Value, error) {
	return json.Marshal(e)
}

type CustomProvider struct {
	Id            string        `db:"id"`
	OrgId         string        `db:"org_id"`
	Name          string        `db:"name"`
	BaseUrl       string        `db:"base_url"`
	SkipAuth      bool          `db:"skip_auth"`
	ApiKeyEnvVar  string        `db:"api_key_env_var"`
	ExtraAuthVars ExtraAuthVars `db:"extra_auth_vars"`
	CreatedAt     time.Time     `db:"created_at"`
	UpdatedAt     time.Time     `db:"updated_at"`
}

View on GitHub (pinned to e2d772072e)

Solutions

  1. Cast the column to text in SQL: SELECT extra_auth_vars::text FROM ...
  2. Check which driver is in use and pin to one with stable text scanning (lib/pq or pgx stdlib)
  3. Add a time.Time/no-op case or nil handling in Scan if NULLs are the trigger
  4. Confirm migrations so the column type matches the model expectation

Example fix

// before
SELECT extra_auth_vars FROM orgs WHERE id = $1
// after
SELECT extra_auth_vars::text AS extra_auth_vars FROM orgs WHERE id = $1
Defensive patterns

Strategy: type-guard

Validate before calling

// in SQL, coerce to text so Scan always receives a string/[]byte:
// SELECT extra_auth_vars::text FROM orgs WHERE id = $1

Type guard

func canScanExtraAuthVars(src any) bool {
    switch src.(type) {
    case []byte, string, nil:
        return true
    default:
        return false
    }
}

Try / catch

var v ExtraAuthVars
if err := row.Scan(&v); err != nil {
    if strings.Contains(err.Error(), "unsupported data type") {
        log.Printf("driver returned non-text for json column: %v", err)
        // rescan via a ::text query or fall back to empty struct
        v = ExtraAuthVars{}
    }
    return err
}

Prevention

When it happens

Trigger: A SELECT on a column backing ExtraAuthVars whose value arrives as a type other than []byte/string (e.g. jsonb scanned into map[string]interface{} by some drivers, NULL handled oddly, or the column bound to a non-text type).

Common situations: Driver upgrades changing scan types for json/jsonb columns; using a proxy or non-postgres driver (e.g. pgx stdlib mode differences); hand-rolled queries that cast the column to a non-text type.

Related errors


AI-assisted analysis of plandex-ai/plandex@e2d772072e (2026-09-05). Data as JSON: /api/errors/51c00f3a859adb24. Report an issue: GitHub.