Skip to content

Fix three bugs: ApiVersion update, CancellationToken passthrough, cache key collisions - #26

Merged
David Burg (daviburg) merged 9 commits into
mainfrom
fix/lsp-bugs-5-6-7
Apr 11, 2026
Merged

David Burg (daviburg) merged 9 commits into
mainfrom
fix/lsp-bugs-5-6-7

Conversation

@daviburg

Copy link
Copy Markdown
Member

Summary

Fixes three bugs identified during PR #4 review.

Bug fixes

  1. ApiServiceConfig.UpdateFrom missing ApiVersion (Closes ApiServiceConfig.UpdateFrom does not update ApiVersion #7)

    • \UpdateFrom()\ now updates the \ApiVersion\ property, matching the pattern of the other properties.
  2. GenerateDynamicSchemaCommandHandler ignores CancellationToken (Closes GenerateDynamicSchemaCommandHandler ignores CancellationToken #6)

    • \Handle()\ now passes the incoming \cancellationToken\ to \FetchSchemaAsync()\ instead of \CancellationToken.None.
  3. ApiService cache key uses GetHashCode (Closes ApiService cache key uses GetHashCode which can cause collisions #5)

    • Both \PostJsonAsync\ overloads now use SHA-256 hashing instead of \GetHashCode()\ for cache key computation. \GetHashCode()\ is not deterministic across .NET runtimes and can produce collisions.

Testing

  • All 94 tests pass, 15 skipped (pre-existing)
  • Build succeeds with zero warnings

ApiServiceConfig.UpdateFrom() was missing the ApiVersion property update,
so runtime config updates via the custom/updateApiConfig LSP notification
could not change it.
Handle() was passing CancellationToken.None to the schema fetch operation
instead of the incoming cancellationToken, preventing proper cancellation.
PostJsonAsync methods used GetHashCode() on serialized JSON payloads as
cache key components. GetHashCode() is not deterministic across .NET
runtimes and can produce collisions. Replaced with SHA-256 hash.
@daviburg
David Burg (daviburg) requested a review from a team as a code owner April 10, 2026 14:51
Copilot AI review requested due to automatic review settings April 10, 2026 14:51

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Fixes three correctness issues in the server’s API/config handling and schema generation command flow: config updates now include API version, schema fetch respects caller cancellation, and API response caching keys are made deterministic and collision-resistant.

Changes:

  • Update ApiServiceConfig.UpdateFrom to propagate ApiVersion when provided.
  • Pass the incoming CancellationToken through to dynamic schema fetching.
  • Replace non-deterministic GetHashCode() cache-key hashing with deterministic SHA-256 hashing for POST payloads.

Reviewed changes

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

File Description
Server/Services/Api/ApiServiceConfig.cs Ensures ApiVersion is updated consistently with other config fields in UpdateFrom.
Server/Services/Api/ApiService.cs Makes POST cache keys deterministic by hashing serialized payloads with SHA-256.
Server/Handlers/CodeActionHandler/GenerateDynamicSchemaCommandHandler.cs Fixes cancellation propagation by passing the handler token into FetchSchemaAsync.

David Burg (daviburg) and others added 2 commits April 10, 2026 12:04
resolveSdkNupkgPath now checks the sibling Connectors-NET-SDK repo's build
output (../../Connectors-NET-SDK/src/*/bin/Debug/*.nupkg) as a fallback
when no explicit sdkNupkgPath setting or workspace SDK/ folder is found.
This mirrors the existing sibling server DLL discovery pattern.

Also updates launch.json to open the Connectors-NET-Samples workspace
in the Extension Development Host for proper end-to-end testing.

Extracted findNewestNupkgInDir helper to reduce duplication.
PR #33 superseded the SDK resolution refactoring in extension.ts. All 6 conflicts resolved by taking main's version. PR #26's 3 bug fixes (ApiVersion update, CancellationToken passthrough, SHA-256 cache keys) are preserved.

Co-authored-by: Dobby <dobby@microsoft.com>
Copilot AI review requested due to automatic review settings April 11, 2026 06:31
@daviburg David Burg (daviburg) self-assigned this Apr 11, 2026

Copilot AI left a comment

Copy link
Copy Markdown

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

Comment thread vscode-extension/.vscode/launch.json Resolved
Comment thread Server/Services/Api/ApiService.cs Resolved
Comment thread Server/Services/Api/ApiService.cs Resolved
- Reuse pre-serialized JSON for POST body instead of re-serializing via PostAsJsonAsync
- Split launch.json into basic config and opt-in config with Samples workspace path

Co-authored-by: Dobby <dobby@microsoft.com>

Copilot AI left a comment

Copy link
Copy Markdown

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

Comment thread Server/Services/Api/ApiService.cs Resolved
Comment thread Server/Services/Api/ApiService.cs Resolved
Use SerializeToUtf8Bytes + ByteArrayContent so payload bytes are allocated once
and shared between SHA-256 hashing and HTTP body.

Co-authored-by: Dobby <dobby@microsoft.com>

Copilot AI left a comment

Copy link
Copy Markdown

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 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread Server/Services/Api/ApiService.cs Resolved
Co-authored-by: Dobby <dobby@microsoft.com>

Copilot AI left a comment

Copy link
Copy Markdown

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 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread Server/Services/Api/ApiServiceConfig.cs Resolved
ApiVersion now defaults to string.Empty (like other properties) so UpdateFrom
partial updates work correctly. EffectiveApiVersion property applies the
2018-07-01-preview default at the point of use.

Co-authored-by: Dobby <dobby@microsoft.com>

Copilot AI left a comment

Copy link
Copy Markdown

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 7 changed files in this pull request and generated no new comments.

@daviburg
David Burg (daviburg) merged commit 04b1c2b into main Apr 11, 2026
12 checks passed
@daviburg
David Burg (daviburg) deleted the fix/lsp-bugs-5-6-7 branch April 11, 2026 06:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants