Skip to content

[Fix] Prompt and get acknowledge to update the missing projectGuid in sqlprojects#21524

Open
ssreerama wants to merge 18 commits intomainfrom
sai/mar/ssdtProjGuidFix
Open

[Fix] Prompt and get acknowledge to update the missing projectGuid in sqlprojects#21524
ssreerama wants to merge 18 commits intomainfrom
sai/mar/ssdtProjGuidFix

Conversation

@ssreerama
Copy link
Contributor

@ssreerama ssreerama commented Mar 9, 2026

Description

This pull request :

  • Ensures SQL projects have a valid ProjectGuid, which is important for cross-project references.
  • The changes add user prompts and automated handling for missing or invalid GUIDs as workspace leve, one toast message for all proejcts.
  • A debounce mechanism collects all projects opened within a 500ms window (the typical workspace load burst) so only one toast is shown instead of one per project. (Reason: there is no bulk hook or completion signal we can listen to)
  • Provided tests for the new behavior.
  • Additionally, a new request type is implemented to support updating project properties for STS handler.

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

image

Prompt_ProjGuid_Missing_workspaceLevel

@github-actions
Copy link

github-actions bot commented Mar 9, 2026

PR Changes

Category Target Branch PR Branch Difference
vscode-mssql VSIX 6454 KB 6452 KB ⚪ -2 KB ( 0% )
sql-database-projects VSIX 7062 KB 7066 KB ⚪ 4 KB ( 0% )
data-workspace VSIX 535 KB 535 KB ⚪ 0 KB ( 0% )

@ssreerama ssreerama self-assigned this Mar 9, 2026
@ssreerama ssreerama added this to the April 2026 Release milestone Mar 9, 2026
@codecov-commenter
Copy link

codecov-commenter commented Mar 9, 2026

Codecov Report

❌ Patch coverage is 64.00000% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.91%. Comparing base (3a32e24) to head (0df71a4).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
...xtensions/mssql/src/services/sqlProjectsService.ts 43.75% 9 Missing ⚠️

❌ Your patch status has failed because the patch coverage (64.00%) is below the target coverage (70.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main   #21524      +/-   ##
==========================================
- Coverage   72.91%   72.91%   -0.01%     
==========================================
  Files         326      326              
  Lines       98731    98756      +25     
  Branches     5569     5570       +1     
==========================================
+ Hits        71992    72008      +16     
- Misses      26739    26748       +9     
Files with missing lines Coverage Δ
...dels/contracts/sqlProjects/sqlProjectsContracts.ts 100.00% <100.00%> (ø)
...xtensions/mssql/src/services/sqlProjectsService.ts 48.04% <43.75%> (-0.10%) ⬇️
🚀 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.

@ssreerama ssreerama marked this pull request as ready for review March 10, 2026 21:00
Copilot AI review requested due to automatic review settings March 10, 2026 21:00
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 adds a new user-facing flow and supporting API surface to ensure SQL projects have a valid ProjectGuid, enabling reliable cross-project references and avoiding the all-zeros GUID behavior seen when <ProjectGuid> is missing.

Changes:

  • Adds a prompt to detect missing/null ProjectGuid and optionally generate/write a new GUID to the project.
  • Introduces a new setProjectProperties request/contract and public typings to update SQL project properties via STS.
  • Adds unit tests and localization strings for the new prompt/label.

Reviewed changes

Copilot reviewed 7 out of 9 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
typings/vscode-mssql.d.ts Exposes setProjectProperties and SetProjectPropertiesParams in the public API typings.
localization/xliff/sql-database-projects.xlf Adds new trans-units for “Add ProjectGuid” and the missing-guid prompt text.
extensions/sql-database-projects/test/project.test.ts Adds tests for prompting behavior and GUID generation/update path.
extensions/sql-database-projects/src/models/project.ts Implements prompt + GUID generation/write logic and calls it during project open/update.
extensions/sql-database-projects/src/common/constants.ts Adds localized label/message constants and the null GUID constant.
extensions/sql-database-projects/l10n/bundle.l10n.json Adds the corresponding localized strings for runtime lookup.
extensions/mssql/typings/vscode-mssql.d.ts Mirrors the public API typing additions in the extension-local typings.
extensions/mssql/src/services/sqlProjectsService.ts Adds client-side setProjectProperties implementation that issues the new request.
extensions/mssql/src/models/contracts/sqlProjects/sqlProjectsContracts.ts Defines the new SetProjectPropertiesRequest request type/route.

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

@ssreerama ssreerama requested a review from dzsquared March 13, 2026 18:01
Copilot AI review requested due to automatic review settings March 13, 2026 18:19
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 7 out of 9 changed files in this pull request and generated 4 comments.


You can also share your feedback on Copilot code review. Take the survey.

allancascante
allancascante previously approved these changes Mar 13, 2026
@allancascante
Copy link
Contributor

@ssreerama please check the failing test before merging the changes.

@ssreerama
Copy link
Contributor Author

@ssreerama please check the failing test before merging the changes.

This PR requires the STS change, probably the failing test is related to it.

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 7 out of 9 changed files in this pull request and generated 2 comments.


You can also share your feedback on Copilot code review. Take the survey.

Copilot AI review requested due to automatic review settings March 18, 2026 21:16
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 7 out of 9 changed files in this pull request and generated 3 comments.


You can also share your feedback on Copilot code review. Take the survey.

Copilot AI review requested due to automatic review settings March 18, 2026 23:01
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 7 out of 9 changed files in this pull request and generated 4 comments.


You can also share your feedback on Copilot code review. Take the survey.

Copilot AI review requested due to automatic review settings March 19, 2026 12:15
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 7 out of 9 changed files in this pull request and generated 5 comments.


You can also share your feedback on Copilot code review. Take the survey.

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 7 out of 9 changed files in this pull request and generated 3 comments.

Comment on lines +248 to +258
public static async checkPromptProjectGuidStatus(projects: Project[]): Promise<void> {
// De-duplicate by projectFilePath in case the same project was queued
// multiple times or this method is called directly with duplicates.
const uniqueProjects = projects.filter(
(p, index, self) =>
self.findIndex((q) => q.projectFilePath === p.projectFilePath) === index,
);

if (uniqueProjects.length === 0) {
return;
}
Copy link

Copilot AI Mar 19, 2026

Choose a reason for hiding this comment

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

checkPromptProjectGuidStatus builds uniqueProjects only by de-duplicating the input list, but it never filters to projects that are currently missing a GUID. This can lead to showing a prompt even when none of the projects passed in actually need fixing (e.g., if a caller passes mixed projects, or a project's GUID is updated between queueing and prompt display). Consider filtering uniqueProjects with isMissingProjectGuid() before building the message, and returning early if the filtered list is empty.

Copilot uses AI. Check for mistakes.
Comment on lines +732 to +741
public async ensureValidProjectGuid(): Promise<void> {
if (!this.isMissingProjectGuid()) {
return;
}
const guid = `{${randomUUID().toUpperCase()}}`;
const result = await this.sqlProjService.setProjectProperties(this.projectFilePath, {
[constants.ProjectGuid]: guid,
});
utils.throwIfFailed(result);
this._projectGuid = guid;
Copy link

Copilot AI Mar 19, 2026

Choose a reason for hiding this comment

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

ensureValidProjectGuid is described as idempotent, but it only checks the in-memory _projectGuid before writing. Since Project.openProject creates new Project instances per call, it’s possible for _projectGuid to be stale relative to the underlying .sqlproj/STS state (e.g., another instance already added a GUID). In that case, this method could overwrite an existing valid GUID. Consider re-reading the current projectGuid from getProjectProperties (or readProjectProperties) immediately before calling setProjectProperties, and only writing when the persisted value is still missing/null.

Copilot uses AI. Check for mistakes.
project2.projectFileName,
]),
),
`showInformationMessage not called with expected message. Actual: "${showInfoStub.firstCall.args[0]}"`,
Copy link

Copilot AI Mar 19, 2026

Choose a reason for hiding this comment

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

This test uses showInfoStub.firstCall.args[0] to report the actual message. Repo review guidance recommends avoiding “n-th call”/call-index inspection (e.g., firstCall, getCall(0)) because it’s brittle. Prefer asserting the stub was called with the expected message using calledWith/calledWithMatch (and, if needed, use a matcher to capture the argument) instead of inspecting a specific call index.

Suggested change
`showInformationMessage not called with expected message. Actual: "${showInfoStub.firstCall.args[0]}"`,
"showInformationMessage not called with expected message",

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: SQL Database Projects generates invalid all-zeros ProjectGuid and modifies files without consent

7 participants