Skip to content

SQL Server driver always sends instanceName, breaking connections to Microsoft Fabric / Synapse serverless #81270

Description

@guilhermerabeloo

Describe the bug

connection-details->spec for the :sqlserver driver always includes :instanceName in the connection spec, even when the "Database instance name" field is left empty.

An empty field yields instance = nil. Metabase's map->properties (in metabase/connection-pool) does (.setProperty p (name k) (str v)), and (str nil) returns "". The Microsoft JDBC driver checks null != instanceValue rather than isEmpty, so the empty string is treated as a valid named instance.

Microsoft Fabric's SQL analytics endpoint drops the connection whenever the property is present, regardless of its value.

This is the same class of bug as #7597, which was fixed for :port in this exact function. :instanceName was left without the same guard:

:instanceName       instance          ;; always included
...
;; only include `port` if it is specified; leave out for dynamic port: see
;; https://github.com/metabase/metabase/issues/7597
(merge (when port {:port port}))      ;; conditionally included

To Reproduce

  1. Add a SQL Server database pointing at a Microsoft Fabric SQL analytics endpoint (<id>.datawarehouse.fabric.microsoft.com, port 1433).
  2. Leave "Database instance name" empty.
  3. Save.
    The connection fails.

Expected behavior

instanceName should only be sent when the user actually supplies a value, matching the existing behavior of port.

Logs

SQL Server did not return a response

The connection is dropped during login. Nothing further is logged, and the message gives no indication that instanceName is involved.

Information about your Metabase installation

- Metabase version: v0.61.3.3 (OSS, self-hosted JAR)
- OS: Ubuntu 24.04
- Java: OpenJDK 21
- Application database: PostgreSQL
- Driver: `:sqlserver` (mssql-jdbc 13.2.1, bundled)

Severity

Blocks all connections to Microsoft Fabric (Lakehouse SQL analytics endpoint and Warehouse) and to Azure Synapse serverless, where named instances do not exist. It affects every user of these services regardless of authentication method. There is no workaround from the UI: additional JDBC options do not override it, because supplied Properties take precedence over URL-parsed values in mssql-jdbc. ---

Additional context

Evidence

Tested directly against the Fabric endpoint, using the exact property set Metabase builds (applicationName, sendTimeAsDatetime=false, encrypt=true, loginTimeout=10, database). Verified on mssql-jdbc 12.10.0 and 13.2.1:

instanceName port result
"" 1433 SQL Server did not return a response
"" empty host connection failure (UDP 1434 lookup)
"MSSQLSERVER" 1433 SQL Server did not return a response
omitted 1433 OK
omitted empty OK

Rows 1 and 3 are identical, which shows the failure does not depend on the value. Row 2 produces a different error, which confirms "" is being treated as a named instance and triggers the SQL Server Browser lookup path.

Suggested fix

Remove :instanceName instance from the base map and emit it conditionally alongside port:

(merge (when port {:port port})
       (when-not (str/blank? instance) {:instanceName instance}))

clojure.string is already required as str in the namespace.

I've been running this patch in production against a Fabric SQL analytics endpoint: the connection succeeds, sync discovers all tables, and temporal bucketing queries run correctly. Existing connections to Azure SQL Database are unaffected.

Happy to open a PR if useful.

Relationship to #37493

Related to #37493, but independent: this failure happens before authentication is ever attempted, so it affects Fabric users who don't need Entra ID at all. It also explains why several people in that thread report that Fabric "just doesn't connect" — the failure looks like an authentication problem when it isn't.

Metadata

Metadata

Assignees

Labels

.Needs Triage.Team/QueryingPlatformPriority:P1Security holes w/o exploit, crashing, setup/upgrade, login, broken common features, correctnessType:BugProduct defects

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions