Skip to content

Fix requireLocalPort for range, regex, and host-and-port rules - #344185

Merged
Alex Ross (alexr00) merged 4 commits into
microsoft:mainfrom
kinqsradio:fix/require-local-port-matching
Oct 28, 2026
Merged

Alex Ross (alexr00) merged 4 commits into
microsoft:mainfrom
kinqsradio:fix/require-local-port-matching

Conversation

@kinqsradio

@kinqsradio Anh Dang (kinqsradio) commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #344184.

Matching port-range, process-regex, and host-and-port rules discarded requireLocalPort, so requesting a warning when the local port changes had no effect. Merge the matched value while preserving explicit false and existing rule precedence. An exact-port rule that omits the flag also preserves a value inherited from an earlier matching range.

Adds 15 tests covering all three selectors with true, false, and unset values, unmatched-rule fallback, exact-port precedence, range/regex precedence, and a range flag combined with an exact-port label. The fallback interaction tests use rules containing only requireLocalPort and populated remote.otherPortsAttributes; matching empty rules and rules with no defined attributes remain eligible for fallback.

Behavior change: a range, process-regex, or host-and-port rule that sets only requireLocalPort now resolves an attribute, so remote.otherPortsAttributes no longer supplies its onAutoForward, label, or elevateIfNeeded values for that port. This applies to both explicit true and explicit false, matching existing exact-port behavior. Previously, dropping the flag made these rules accidentally use the fallback. For example, fallback onAutoForward: "ignore" no longer suppresses automatic forwarding for a port covered by such a rule; put onAutoForward: "ignore" on the matching rule if that behavior is wanted. The existing fallback-selection logic is unchanged.

Validation of the runtime fix on f8f2501f:

  • Original baseline: 4 passing controls and 4 expected failures for the dropped attribute.
  • Copilot's mixed-rule case: an additional regression test failed before the exact-port merge correction.
  • After both corrections: 21 passing browser tests across the new suite and adjacent remote-resource, automatic-forwarding, and URL-finder suites.
  • Full client typecheck passed: npm run typecheck-client, no diagnostics.
  • Client build (npm run build-fast -- --client-only), targeted ESLint, and git diff --check passed.
  • Independent source review found no actionable issues after the follow-up correction.

Test-only follow-up on 531b4772:

  • Added six fallback-interaction tests and strengthened the three unmatched-rule tests; production code is unchanged from f8f2501f.
  • With the original two compiled assignments temporarily restored, the three flag-only tests failed as expected and the three empty/unset-rule controls passed. The current compiled output was restored before candidate verification.
  • All 27 browser tests passed across the same four suites after the follow-up; incremental client build, targeted ESLint, and git diff --check passed.
  • The full client typecheck and native run below were performed on f8f2501f; they were not rerun for this test-only follow-up. The new fallback interactions were verified in the browser unit suite, not separately in the desktop app.

Native end-to-end verification used the rebuilt Code OSS Dev 1.144.0 client on macOS with the repository's Electron 43.8.3 runtime and the controlled TCP fixture described in #344184:

  • Range with requireLocalPort: true: native mismatch warning shown.
  • Range with true plus an exact-port rule defining only a label: native warning shown.
  • Exact port with true: native warning shown.
  • Exact port with false: no warning.
  • All four actual TCP forwards returned HTTP 200 with the expected response, with attempts spaced beyond the dialog cooldown.

This native run uses a local tunnel provider, not Remote SSH or Dev Containers. Native regex and host-and-port dialogs were not separately exercised; their attribute resolution is covered by the browser regression suite. Uncompiled built-in extensions in the client-only development build reported unrelated activation errors; the fixture registered and all four controlled forwarding paths completed.

Copilot AI balanced review requested due to automatic review settings October 26, 2026 02:15

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The exact-port branch still resets a range or regex requireLocalPort: true to undefined when the exact rule leaves the flag unset, so the warning can still be lost.

2 open issues

Review effort: Lite

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The core fix is small, but it changes default fallback behavior for flag-only range, regex, and host-and-port rules, which the PR does not mention or test.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Medium severity Document or test changed defaults for requireLocalPort-only rules

src/​vs/​workbench/​services/​remote/​common/​tunnelModel.ts:239

Behavior change: a range, regex, or host-and-port rule that sets only requireLocalPort now counts as a match. Before this change, such a rule fell back to remote.otherPortsAttributes, so the defaults for onAutoForward, label, and elevateIfNeeded applied to those ports. Those defaults are now skipped. This matches how exact-port rules already behave, but the PR does not mention it and no test covers it. Please confirm this is intended, then document it or add a test that asserts it.

2 resolved since last review

Review effort: Lite

@alexr00 Alex Ross (alexr00) modified the milestones: 1.144.0, 1.145.0 Oct 28, 2026
@alexr00
Alex Ross (alexr00) enabled auto-merge (squash) October 28, 2026 09:34

@alexr00 Alex Ross (alexr00) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the PR!

@alexr00
Alex Ross (alexr00) merged commit 2b8540d into microsoft:main Oct 28, 2026
51 checks passed
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.

remote.portsAttributes: requireLocalPort is ignored for port ranges

4 participants