{"record":{"id":"1641f4944558cbfd","repo":"googleapis/mcp-toolbox","slug":"unable-to-get-alloydb-connection-config-w","errorCode":null,"errorMessage":"unable to get AlloyDB connection config: %w","messagePattern":"unable to get AlloyDB connection config: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/alloydbpg/alloydb_pg.go","lineNumber":218,"sourceCode":"\n\tif readOnly {\n\t\t// IMPORTANT: Must use underscore ('alloydb_session_read_only'), NOT a dot.\n\t\t// PostgreSQL treats dotted GUCs (e.g. 'alloydb.session_read_only') as custom placeholders\n\t\t// and silently ignores them at connection time, leaving the session in read-write mode.\n\t\tdsn += \" options='-c alloydb_session_read_only=locked'\"\n\t}\n\n\treturn dsn, useIAM, nil\n}\n\nfunc initAlloyDBPgConnectionPool(ctx context.Context, tracer trace.Tracer, name, project, region, cluster, instance, ipType, user, pass, dbname string, readOnly bool) (*pgxpool.Pool, error) {\n\t//nolint:all // Reassigned ctx\n\tctx, span := sources.InitConnectionSpan(ctx, tracer, SourceType, name)\n\tdefer span.End()\n\n\tdsn, useIAM, err := getConnectionConfig(ctx, user, pass, dbname, readOnly)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to get AlloyDB connection config: %w\", err)\n\t}\n\n\tconfig, err := pgxpool.ParseConfig(dsn)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to parse connection uri: %w\", err)\n\t}\n\t// Create a new dialer with options\n\tuserAgent, err := util.UserAgentFromContext(ctx)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\topts, err := getOpts(ipType, userAgent, useIAM)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\td, err := alloydbconn.NewDialer(ctx, opts...)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to parse connection uri: %w\", err)","sourceCodeStart":200,"sourceCodeEnd":236,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/alloydbpg/alloydb_pg.go#L200-L236","documentation":"initAlloyDBPgConnectionPool wraps any error returned by getConnectionConfig (credential resolution, DSN construction, invalid ipType/option combination) with this message before the pool can be created. It means the source could not compute a valid connection string for the AlloyDB instance, so pool initialization is aborted. The underlying cause is chained via %w and is the real diagnostic.","triggerScenarios":"Calling Initialize on the alloydbpg source when: user/password rules are violated (password without username), ADC email lookup fails (see error 430), the ipType option is invalid, or the UserAgent cannot be derived downstream — any failure inside getConnectionConfig.","commonSituations":"Typos or bad values in the YAML config (e.g. invalid ipType), half-configured IAM auth (password set but user empty), missing GCP credentials in the deployment environment, or invalid project/region/cluster/instance strings feeding the DSN template.","solutions":["Read the wrapped cause after 'unable to get AlloyDB connection config:' — fix that root cause first.","If using IAM auth (empty user/pass), ensure ADC is configured and the identity can access AlloyDB.","Provide both username and password together, or leave both empty; never provide only a password.","Validate the ipType value (public|private) and network reachability settings in the source config."],"exampleFix":"// before: password without username\n{\"user\": \"\", \"pass\": \"secret\", ...}\n// after: supply both\n{\"user\": \"appuser\", \"pass\": \"secret\", ...}","handlingStrategy":"try-catch","validationCode":"if (pass == \"\") != (user == \"\") {\n    return errors.New(\"provide both user and password, or neither for IAM auth\")\n}","typeGuard":null,"tryCatchPattern":"_, err := initAlloyDBPgConnectionPool(ctx, cfg)\nif err != nil {\n    var cfgErr *fmt.ConfigError\n    if errors.As(err, &cfgErr) { /* fix config */ }\n    return fmt.Errorf(\"pool init failed: %w\", err)\n}","preventionTips":["Always supply user and password together, or leave both empty for IAM auth.","Validate ipType against allowed values (public/private) before Initialize.","Ensure ADC is configured before relying on IAM auth.","Log the full error chain (%w causes) rather than only the top-level message."],"tags":["gcp","alloydb","configuration","connection"],"backgroundTag":"connection-config-invalid","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"}