{"record":{"id":"41e43dfc0616cb67","repo":"googleapis/mcp-toolbox","slug":"unsupported-dbtype-s-use-mysql-or-postgres","errorCode":null,"errorMessage":"unsupported dbType: %s. Use 'mysql' or 'postgres'","messagePattern":"unsupported dbType: (.+?)\\. Use 'mysql' or 'postgres'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/util.go","lineNumber":136,"sourceCode":"\t}\n\n\tfullEmail, ok := emailValue.(string)\n\tif !ok {\n\t\treturn \"\", fmt.Errorf(\"email field is not a string\")\n\t}\n\n\tvar username string\n\t// Format the username based on Database Type\n\tswitch strings.ToLower(dbType) {\n\tcase \"mysql\":\n\t\tusername, _, _ = strings.Cut(fullEmail, \"@\")\n\n\tcase \"postgres\":\n\t\t// service account email used for IAM should trim the suffix\n\t\tusername = strings.TrimSuffix(fullEmail, \".gserviceaccount.com\")\n\n\tdefault:\n\t\treturn \"\", fmt.Errorf(\"unsupported dbType: %s. Use 'mysql' or 'postgres'\", dbType)\n\t}\n\n\tif username == \"\" {\n\t\treturn \"\", fmt.Errorf(\"username from ADC cannot be an empty string\")\n\t}\n\n\treturn username, nil\n}\n\nfunc GetIAMAccessToken(ctx context.Context) (string, error) {\n\tcreds, err := google.FindDefaultCredentials(ctx, \"https://www.googleapis.com/auth/cloud-platform\")\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to find default credentials (run 'gcloud auth application-default login'?): %w\", err)\n\t}\n\n\ttoken, err := creds.TokenSource.Token() // This gets an oauth2.Token\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to get token from token source: %w\", err)","sourceCodeStart":118,"sourceCodeEnd":154,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/util.go#L118-L154","documentation":"GetIAMPrincipalEmailFromADC derives the IAM principal email from Application Default Credentials for Cloud SQL IAM authentication. It only supports 'mysql' and 'postgres' dbTypes; any other value (including empty or typos like 'postgresql') hits the default branch and returns this error. The library throws it to fail fast rather than attempt IAM auth against an unsupported database engine.","triggerScenarios":"Calling getConnectionConfig (which calls GetIAMPrincipalEmailFromADC) with a Cloud SQL source whose dbType is not exactly 'mysql' or 'postgres' — e.g. 'postgresql', 'sqlserver', 'mssql', or an unset/empty dbType in the source config.","commonSituations":"Typo in the source kind (using 'postgresql' instead of 'postgres'); using Cloud SQL IAM auth fields with an unsupported engine like SQL Server; a config file where dbType is omitted or mis-indented in YAML.","solutions":["Fix the dbType in your source config to exactly 'mysql' or 'postgres' (lowercase)","If using Postgres, use kind 'postgres', not 'postgresql'","If your database is not MySQL or Postgres, do not use ADC-based IAM auth; use a standard username/password connection instead"],"exampleFix":"// before\nsources:\n  my-pg:\n    kind: postgresql\n// after\nsources:\n  my-pg:\n    kind: postgres","handlingStrategy":"validation","validationCode":"const allowed = new Set([\"mysql\", \"postgres\"]);\nif (!allowed.has(dbType)) {\n  throw new Error(`dbType must be 'mysql' or 'postgres', got: ${dbType}`);\n}","typeGuard":"function isSupportedDbType(v: string): v is \"mysql\" | \"postgres\" {\n  return v === \"mysql\" || v === \"postgres\";\n}","tryCatchPattern":null,"preventionTips":["Copy dbType values verbatim from official docs ('postgres', not 'postgresql')","Validate your tools.yaml source kinds against supported values before startup","Add a config linter/schema check in CI for source kinds"],"tags":["config","iam-auth","cloud-sql","google-cloud"],"backgroundTag":"unsupported-database-type","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}