[Fix] Adding default sdk version incase config inspect returns null#21449
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses a packaging-only issue where VS Code configuration defaults for sqlDatabaseProjects.microsoftBuildSqlVersion are not available (via config.inspect) in the pipeline-generated VSIX, causing the SDK version to resolve to empty/undefined. The change adds an explicit fallback so the extension can still pick a usable Microsoft.Build.Sql SDK version at runtime.
Changes:
- Added a hardcoded default Microsoft.Build.Sql SDK version constant (
2.1.0) with guidance to keep it in sync withpackage.json. - Updated
getMicrosoftBuildSqlVersion()to fall back to the hardcoded value whenconfig.inspect(...).defaultValueis missing.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
PR Changes
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #21449 +/- ##
=======================================
Coverage 72.83% 72.83%
=======================================
Files 325 325
Lines 96419 96419
Branches 5411 5411
=======================================
Hits 70227 70227
Misses 26192 26192 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return defaultValue; | ||
|
|
||
| // Read the default value from package.json | ||
| const extension = vscode.extensions.getExtension(sqldbproj.extension.vsCodeName); |
There was a problem hiding this comment.
I don't love this method as a work-around. Reading config should be trivial, so let's just do this correctly instead.
There was a problem hiding this comment.
done, as per the discussion i have added the fallback version constant and comments for future understanding.
There was a problem hiding this comment.
Why does this method need to take in a config string? Is it ever anything different from sqlDatabaseProjects.microsoftBuildSqlVersion?
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const defaultValue = config.inspect<string>(microsoftBuildSqlVersionKey)?.defaultValue ?? ""; | ||
| return defaultValue; | ||
|
|
||
| // Fall back to the hardcoded constant if config value is unavailable or invalid |
There was a problem hiding this comment.
The docstring describes a 3-step resolution order (including “package.json default value”), but the implementation always returns the hardcoded constant for any invalid/blank value and never attempts to read inspect(...).defaultValue. This creates a drift risk if the package.json default changes but FALLBACK_MICROSOFT_BUILD_SQL_VERSION isn’t updated. Consider restoring a guarded config.inspect(...).defaultValue fallback (validate with semver.valid) and only use FALLBACK_MICROSOFT_BUILD_SQL_VERSION when inspect is missing/invalid.
| // Fall back to the hardcoded constant if config value is unavailable or invalid | |
| // If the user value is missing/invalid, try the package.json default (if present and valid) | |
| const inspected = config.inspect<string>(microsoftBuildSqlVersionKey); | |
| if (inspected && typeof inspected.defaultValue === "string") { | |
| const defaultValue = inspected.defaultValue.trim(); | |
| if (defaultValue && semver.valid(defaultValue)) { | |
| return defaultValue; | |
| } | |
| } | |
| // Fall back to the hardcoded constant if both config and package.json default are unavailable or invalid |
| test("Should fall back to FALLBACK_MICROSOFT_BUILD_SQL_VERSION when configured value is invalid or empty", async function (): Promise<void> { | ||
| // Test with invalid semver | ||
| await vscode.workspace | ||
| .getConfiguration(DBProjectConfigurationKey) | ||
| .update( | ||
| constants.microsoftBuildSqlVersionKey, | ||
| "not-a-valid-version", | ||
| vscode.ConfigurationTarget.Global, | ||
| ); | ||
| let result = getMicrosoftBuildSqlVersion(); | ||
| expect(result).to.equal(FALLBACK_MICROSOFT_BUILD_SQL_VERSION); | ||
|
|
||
| // Test with empty config | ||
| await vscode.workspace | ||
| .getConfiguration(DBProjectConfigurationKey) | ||
| .update( | ||
| constants.microsoftBuildSqlVersionKey, | ||
| undefined, | ||
| vscode.ConfigurationTarget.Global, | ||
| ); | ||
| result = getMicrosoftBuildSqlVersion(); | ||
| expect(result).to.equal(FALLBACK_MICROSOFT_BUILD_SQL_VERSION); | ||
| }); |
There was a problem hiding this comment.
The “empty config” case uses update(..., undefined, ...), which typically removes the user override and allows config.get(...) to return the package.json default (not “empty”). This assertion will become incorrect if the package.json default ever differs from FALLBACK_MICROSOFT_BUILD_SQL_VERSION, and it doesn’t accurately test a blank/empty user value. Suggest changing this to explicitly set an empty string (e.g., "") to validate the “blank” path, or else assert the package default behavior for the “unset” scenario.
| await vscode.workspace | ||
| .getConfiguration(DBProjectConfigurationKey) | ||
| .update( | ||
| constants.microsoftBuildSqlVersionKey, | ||
| undefined, | ||
| vscode.ConfigurationTarget.Global, | ||
| ); |
There was a problem hiding this comment.
These tests write to vscode.ConfigurationTarget.Global, which can leak state if the test process is interrupted or a failure prevents cleanup. Prefer writing to ConfigurationTarget.Workspace (or a workspace-folder target) to keep tests isolated and avoid modifying the developer/machine global settings during test runs.

Description
Pipeline generated VSIX file does not returns the config defaults (investigating what could be the reason).
Code Changes Checklist
npm run test)Reviewers: Please read our reviewer guidelines
Before: Was able to repro with the 1.5.8version install

After: (locally, always working without the fallback version)
