{"record":{"id":"04240a49a6566d32","repo":"googleapis/mcp-toolbox","slug":"unable-to-parse-connection-uri-w-04240a","errorCode":null,"errorMessage":"unable to parse connection uri: %w","messagePattern":"unable to parse connection uri: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/postgres/postgres.go","lineNumber":163,"sourceCode":"func initPostgresConnectionPool(ctx context.Context, tracer trace.Tracer, name, host, port, user, pass, dbname string, queryParams map[string]string, queryExecMode string, connectTimeout *int) (*pgxpool.Pool, error) {\n\t//nolint:all // Reassigned ctx\n\tctx, span := sources.InitConnectionSpan(ctx, tracer, SourceType, name)\n\tdefer span.End()\n\tuserAgent, err := util.UserAgentFromContext(ctx)\n\tif err != nil {\n\t\tuserAgent = \"genai-toolbox\"\n\t}\n\tif queryParams == nil {\n\t\t// Initialize the map before using it\n\t\tqueryParams = make(map[string]string)\n\t}\n\tif _, ok := queryParams[\"application_name\"]; !ok {\n\t\tqueryParams[\"application_name\"] = userAgent\n\t}\n\n\tconfig, err := pgxpool.ParseConfig(BuildPostgresURL(host, port, user, pass, dbname, queryParams))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to parse connection uri: %w\", err)\n\t}\n\n\texecMode, err := ParseQueryExecMode(queryExecMode)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tconfig.ConnConfig.DefaultQueryExecMode = execMode\n\n\tif connectTimeout != nil {\n\t\tconfig.ConnConfig.ConnectTimeout = time.Duration(*connectTimeout) * time.Second\n\t}\n\n\tpool, err := pgxpool.NewWithConfig(ctx, config)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to create connection pool: %w\", err)\n\t}\n\n\treturn pool, nil","sourceCodeStart":145,"sourceCodeEnd":181,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/postgres/postgres.go#L145-L181","documentation":"pgxpool.ParseConfig rejected the connection URI assembled by BuildPostgresURL from the configured host, port, user, password, database and queryParams — at least one of these fields produces a malformed DSN (bad port, unescaped credentials, or invalid query parameter).","triggerScenarios":"Thrown at internal/sources/postgres/postgres.go:163 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify host, port, user, password, database and connectionParams values in the source's YAML configuration","URL-encode any special characters in the password or query parameter values","Test the assembled URI locally with psql or pgxpool.ParseConfig to reproduce the parse failure"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}