Repository navigation
Fix exact-port rule clearing inherited protocol from range - #344775
Closed
Ayush Kr Singh (ayushkrsingh946) wants to merge 2 commits into
Closed
Ayush Kr Singh (ayushkrsingh946) wants to merge 2 commits into
Ayush Kr Singh (ayushkrsingh946) wants to merge 2 commits into
Conversation
Fixes microsoft#344750. When resolving port attributes, an exact-port rule that omits protocol (such as an entry setting only a label) should preserve any protocol inherited from a matching range or regex rule, while an exact rule that explicitly sets a protocol should override it. In PortsAttributes.getAttributes, use found.protocol ?? attributes.protocol instead of unconditionally assigning found.protocol, matching the behavior of other attributes.
Contributor
Author
|
@microsoft-github-policy-service agree |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the change preserving inherited port protocols.
No open issues 🎉
What changed in this PR
Fixes #344750 by preserving an inherited port protocol when an exact-port rule omits protocol, preventing the Ports view from incorrectly falling back to HTTP.
Changes:
- Retains the accumulated protocol unless the exact-port rule explicitly overrides it.
- Adds tests for protocol inheritance and exact-port precedence using both HTTP and HTTPS.
| File | Description |
|---|---|
src/vs/workbench/services/remote/test/browser/tunnelModel.test.ts |
Adds protocol support to the test helper and regression tests for inheritance and precedence. |
src/vs/workbench/services/remote/common/tunnelModel.ts |
Preserves the inherited protocol when an exact-port rule leaves it unset. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #344750.
Problem
An exact-port rule in
remote.portsAttributesthat omitsprotocol(for instance, a rule that only sets alabelsuch as"3500": { "label": "Application" }) clears the protocol inherited from an overlapping port range (e.g."3000-4000": { "protocol": "https" }). BecausesortAttributesorders rules by start port / exact port, the range rule runs first and setsattributes.protocol = 'https', but the exact-port rule then unconditionally assigned:which overwrote
attributes.protocolback toundefinedwhen omitted by the exact rule. The Ports view consequently falls back to HTTP.Solution
In
PortsAttributes.getAttributes, merge the exact-port protocol with fallback to accumulated attributes:This preserves any protocol inherited from a matching range or regex rule when the exact-port rule leaves
protocolunset, while still allowing an exact-port rule with an explicit protocol to override it.Tests
src/vs/workbench/services/remote/test/browser/tunnelModel.test.ts:preserves exact-port protocol over matching range and regex rulespreserves range protocol when an exact-port rule leaves it unsetPortsAttributessuite passing 17/17).npm run typecheck-clientand ESLint pass with no errors.