{"record":{"id":"a8f0a4fcff6a869e","repo":"googleapis/mcp-toolbox","slug":"failed-to-build-dsn-w","errorCode":null,"errorMessage":"failed to build DSN: %w","messagePattern":"failed to build DSN: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/trino/trino.go","lineNumber":174,"sourceCode":"\t\tout = append(out, vMap)\n\t}\n\n\tif err := results.Err(); err != nil {\n\t\treturn nil, fmt.Errorf(\"errors encountered during row iteration: %w\", err)\n\t}\n\n\treturn out, nil\n}\n\nfunc initTrinoConnectionPool(ctx context.Context, tracer trace.Tracer, name, host, port, user, password, catalog, schema, queryTimeout, accessToken string, kerberosEnabled, sslEnabled bool, sslCertPath, sslCert string, disableSslVerification bool) (*sql.DB, error) {\n\t//nolint:all // Reassigned ctx\n\tctx, span := sources.InitConnectionSpan(ctx, tracer, SourceType, name)\n\tdefer span.End()\n\n\t// Build Trino DSN\n\tdsn, err := buildTrinoDSN(host, port, user, password, catalog, schema, queryTimeout, accessToken, kerberosEnabled, sslEnabled, sslCertPath, sslCert)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to build DSN: %w\", err)\n\t}\n\n\tlogger, err := util.LoggerFromContext(ctx)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to get logger from ctx: %s\", err)\n\t}\n\n\tif disableSslVerification {\n\t\tlogger.WarnContext(ctx, \"SSL verification is disabled for trino source %s. This is an insecure setting and should not be used in production.\\n\", name)\n\t\ttr := &http.Transport{\n\t\t\tTLSClientConfig: &tls.Config{InsecureSkipVerify: true},\n\t\t}\n\t\tclient := &http.Client{Transport: tr}\n\t\tclientName := fmt.Sprintf(\"insecure_trino_client_%s\", name)\n\t\tif err := trinogo.RegisterCustomClient(clientName, client); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to register custom client: %w\", err)\n\t\t}\n\t\tdsn = fmt.Sprintf(\"%s&custom_client=%s\", dsn, clientName)","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/trino/trino.go#L156-L192","documentation":"initTrinoConnectionPool wraps buildTrinoDSN failures with this message. buildTrinoDSN composes the trino:// DSN including query parameters for auth, SSL, catalog/schema and query timeout; it errors when required parameters are missing or invalid combinations are requested (e.g. kerberos options or cert material malformed). The underlying error is preserved.","triggerScenarios":"Initialize -> initTrinoConnectionPool where buildTrinoDSN(host, port, user, password, catalog, schema, queryTimeout, accessToken, kerberosEnabled, sslEnabled, sslCertPath, sslCert) returns an error, such as unparsable port/queryTimeout values or invalid cert/kerberos parameter combinations.","commonSituations":"Non-numeric port or queryTimeout strings from YAML; kerberosEnabled=true without required principal/realm config; sslEnabled with a bad sslCertPath or both sslCertPath and inline sslCert conflicting.","solutions":["Inspect the wrapped error for the exact DSN parameter rejected","Validate port and queryTimeout are numeric strings in the trino source config","If SSL is enabled, confirm sslCertPath points to a readable PEM file or remove it to use system roots","Disable kerberos/accessToken flags that aren't needed to simplify the DSN"],"exampleFix":"// before\nqueryTimeout: \"30s\"\n// after\nqueryTimeout: \"30\"  // seconds, numeric","handlingStrategy":"validation","validationCode":"func validateTrinoDSNInputs(port, queryTimeout, sslCertPath string) error {\n    if _, err := strconv.Atoi(port); err != nil { return fmt.Errorf(\"bad port %q\", port) }\n    if queryTimeout != \"\" { if _, err := strconv.Atoi(queryTimeout); err != nil { return fmt.Errorf(\"bad queryTimeout %q\", queryTimeout) } }\n    if sslCertPath != \"\" { if _, err := os.ReadFile(sslCertPath); err != nil { return fmt.Errorf(\"bad sslCertPath: %w\", err) } }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"src, err := cfg.Initialize(ctx, tracer)\nif err != nil && strings.Contains(err.Error(), \"failed to build DSN\") {\n    return fmt.Errorf(\"trino DSN construction failed — check port/queryTimeout/cert params: %w\", err)\n}","preventionTips":["Use plain numeric strings for port and queryTimeout","Point sslCertPath at an existing PEM file; don't set both cert path and inline cert","Keep kerberos/accessToken flags minimal and consistent with your auth mode","Add config schema validation at load time"],"tags":["database","trino","dsn","configuration"],"backgroundTag":"invalid-dsn","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"}