{"record":{"id":"51c00f3a859adb24","repo":"plandex-ai/plandex","slug":"unsupported-data-type-t","errorCode":null,"errorMessage":"unsupported data type: %T","messagePattern":"unsupported data type: %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/server/db/data_models.go","lineNumber":476,"sourceCode":"\t\tCreatedAt: &model.CreatedAt,\n\t\tUpdatedAt: &model.UpdatedAt,\n\t}\n}\n\ntype ExtraAuthVars []shared.ModelProviderExtraAuthVars\n\nfunc (e *ExtraAuthVars) Scan(src interface{}) error {\n\tif src == nil {\n\t\treturn nil\n\t}\n\n\tswitch s := src.(type) {\n\tcase []byte:\n\t\treturn json.Unmarshal(s, e)\n\tcase string:\n\t\treturn json.Unmarshal([]byte(s), e)\n\tdefault:\n\t\treturn fmt.Errorf(\"unsupported data type: %T\", src)\n\t}\n}\n\nfunc (e ExtraAuthVars) Value() (driver.Value, error) {\n\treturn json.Marshal(e)\n}\n\ntype CustomProvider struct {\n\tId            string        `db:\"id\"`\n\tOrgId         string        `db:\"org_id\"`\n\tName          string        `db:\"name\"`\n\tBaseUrl       string        `db:\"base_url\"`\n\tSkipAuth      bool          `db:\"skip_auth\"`\n\tApiKeyEnvVar  string        `db:\"api_key_env_var\"`\n\tExtraAuthVars ExtraAuthVars `db:\"extra_auth_vars\"`\n\tCreatedAt     time.Time     `db:\"created_at\"`\n\tUpdatedAt     time.Time     `db:\"updated_at\"`\n}","sourceCodeStart":458,"sourceCodeEnd":494,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/server/db/data_models.go#L458-L494","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Cast the column to text in SQL: SELECT extra_auth_vars::text FROM ...","Check which driver is in use and pin to one with stable text scanning (lib/pq or pgx stdlib)","Add a time.Time/no-op case or nil handling in Scan if NULLs are the trigger","Confirm migrations so the column type matches the model expectation"],"exampleFix":"// before\nSELECT extra_auth_vars FROM orgs WHERE id = $1\n// after\nSELECT extra_auth_vars::text AS extra_auth_vars FROM orgs WHERE id = $1","handlingStrategy":"type-guard","validationCode":"// in SQL, coerce to text so Scan always receives a string/[]byte:\n// SELECT extra_auth_vars::text FROM orgs WHERE id = $1","typeGuard":"func canScanExtraAuthVars(src any) bool {\n    switch src.(type) {\n    case []byte, string, nil:\n        return true\n    default:\n        return false\n    }\n}","tryCatchPattern":"var v ExtraAuthVars\nif err := row.Scan(&v); err != nil {\n    if strings.Contains(err.Error(), \"unsupported data type\") {\n        log.Printf(\"driver returned non-text for json column: %v\", err)\n        // rescan via a ::text query or fall back to empty struct\n        v = ExtraAuthVars{}\n    }\n    return err\n}","preventionTips":["Cast json/jsonb columns to text in hand-written queries","Pin a single postgres driver version with consistent Scan behavior","Handle NULL explicitly (Scan nil) before the type switch","Test scanning against both lib/pq and pgx if either may be used"],"tags":["database","sql-scan","json","type-mismatch"],"backgroundTag":"sql-scan-unsupported-type","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}