Skip to content

Conversation

@manujoseph85
Copy link
Contributor

@manujoseph85 manujoseph85 commented Feb 12, 2026

Description

The default connection string from the Object Explorer will point to localhost (or other forms) for local sqlserver deployment. For DAB deployed in Docker we need to transform this for DAB (to host.docker.internal) to be able to redirect to host correctly.

  • Added a new sqlServerContainerName property to the Dab.DabConnectionInfo interface
  • transformConnectionInfoForDocker in dabService now checks for localhost and its variants in the provided connection string and transforms it to
    • host.docker.internal\${sqlServerContainerName} for sqlserver in local containers
    • host.docker.internal for local sqlserver instance

Testing and validation:

  • Added extensive unit tests for connection string transformation logic, covering edge cases, localhost variants, containerized SQL Server, and integration with config generation.

Code Changes Checklist

  • New or updated unit tests added
  • All existing tests pass (npm run test)
  • Code follows contributing guidelines
  • Telemetry/logging updated if relevant
  • No regressions or UX breakage

Reviewers: Please read our reviewer guidelines

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements connection string transformation for DAB (Data API Builder) deployments in Docker containers. When DAB runs in a Docker container and needs to connect to SQL Server, localhost references in connection strings must be transformed to enable proper communication across container boundaries.

Changes:

  • Added sqlServerContainerName property to DabConnectionInfo interface to support containerized SQL Server scenarios
  • Implemented transformConnectionInfoForDocker method that replaces localhost variants (localhost, 127.0.0.1, (local), .) with host.docker.internal for Docker networking
  • Updated runDeploymentStep signature to accept DabConnectionInfo instead of just connection string
  • Added comprehensive unit tests covering transformation logic edge cases and integration scenarios

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
extensions/mssql/src/sharedInterfaces/dab.ts Added sqlServerContainerName optional property to DabConnectionInfo interface and updated runDeploymentStep parameter from connectionString to connectionInfo
extensions/mssql/src/services/dabService.ts Implemented transformConnectionInfoForDocker with helper methods to parse and transform localhost addresses; integrated transformation into generateConfig method
extensions/mssql/src/schemaDesigner/schemaDesignerWebviewController.ts Added _sqlServerContainerName field and resolveSqlServerContainerName method to extract container name from connection profile; updated DAB service calls to pass DabConnectionInfo
extensions/mssql/test/unit/dab/dabService.test.ts Added extensive test suites covering localhost variants, port/instance preservation, containerized SQL Server scenarios, and edge cases; updated existing tests to use DabConnectionInfo
extensions/mssql/test/unit/schemaDesignerWebviewController.test.ts Added tests for connection string transformation in config generation and container name resolution from different sources

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions
Copy link

github-actions bot commented Feb 12, 2026

PR Changes

Category Target Branch PR Branch Difference
vscode-mssql VSIX 5976 KB 5972 KB ⚪ -4 KB ( 0% )
sql-database-projects VSIX 7758 KB 7917 KB 🔴 159 KB ( 2% )
data-workspace VSIX 537 KB 536 KB ⚪ -1 KB ( 0% )

@codecov-commenter
Copy link

codecov-commenter commented Feb 12, 2026

Codecov Report

❌ Patch coverage is 97.67442% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 69.21%. Comparing base (a6162a4) to head (66718e3).
⚠️ Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
.../schemaDesigner/schemaDesignerWebviewController.ts 87.50% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #21180      +/-   ##
==========================================
+ Coverage   69.13%   69.21%   +0.07%     
==========================================
  Files         255      255              
  Lines       25160    25200      +40     
  Branches     3284     3293       +9     
==========================================
+ Hits        17395    17441      +46     
+ Misses       7629     7623       -6     
  Partials      136      136              
Files with missing lines Coverage Δ
extensions/mssql/src/deployment/dockerUtils.ts 93.00% <ø> (ø)
extensions/mssql/src/services/dabService.ts 93.70% <100.00%> (+2.12%) ⬆️
extensions/mssql/src/sharedInterfaces/dab.ts 98.27% <ø> (ø)
.../schemaDesigner/schemaDesignerWebviewController.ts 80.09% <87.50%> (+0.80%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

caohai
caohai previously approved these changes Feb 12, 2026
const serverValue = serverMatch[1].trim();

// Parse the server address to check if it's localhost
const host = this.parseHostFromServerValue(serverValue);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this information already in connectionInfo?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

connectionString was already available in DabService. I will file an improvement item for using connectionManager to do the rewrite.

let newServerValue: string;
if (sqlServerContainerName) {
// Extract port if present (comma-separated), discard any instance name
const commaIndex = serverValue.indexOf(",");
Copy link
Contributor

@aasimkhan30 aasimkhan30 Feb 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the connection info object from to get these details directly instead of parsing it from connection string.

I think we should use the original connection info, clone it, mutate it and then create a connection string out of it. It will be less brittle than regexes.

const connectionDetails =
this._mainController.connectionManager.createConnectionDetails(
cleanedConnection,
);
let tempUserId = false;
if (
connectionDetails.options.authenticationType ===
AuthenticationType.AzureMFA &&
connectionDetails.options.user === undefined
) {
// STS call for getting connection string expects a user when AzureMFA is used; if user is not set, set it to empty string
connectionDetails.options.user = "";
tempUserId = true;
}
connectionString =
await this._mainController.connectionManager.getConnectionString(
connectionDetails,
true /* includePassword */,
);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think thats probably the best way to do it too.

Although, we might have to do some more plumbing in SchemaDesignerWebviewController to do that whereas connectionString was already available. We are only replacing in a narrow case - Server part when its localhost. So, I think the regex matches here are less error prone.

So, I will merge this for now and file an improvement item for using connectionManager to do the rewrite.

Copy link
Contributor

@aasimkhan30 aasimkhan30 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good with minor comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants