Repository navigation
Description
Summary
remote.portsAttributes accepts port ranges, but a matching range rule with requireLocalPort: true does not show the documented warning when forwarding uses a different local port. An exact numeric port rule with the same flag correctly shows the warning.
The range still applies its label, so the failure is not that the rule fails to match. requireLocalPort is dropped while resolving the attributes.
Environment and verification scope
- VS Code: 1.119.0-insider, commit
717aa443fdb80afacf21f6050ba976f890b8ea55, arm64. - OS: macOS 26.2, build
25C56. - Installed user extensions disabled; a local extension development host supplied the reproduction fixture.
- VS Code product code was unmodified.
- Source analysis used upstream
mainat4f012f7e4eecac06ab2ecc60d5c17ca686fb9c2a.
Reproduced in the running VS Code desktop app: range rule with true, exact-port rule with true, and exact-port rule with false.
Checked only in an isolated source-class harness: host-and-port and process-command regex rules also lose requireLocalPort: true. Their missing-dialog behavior was not reproduced in the desktop app.
The desktop reproduction uses a controlled local tunnel provider, not a Remote SSH or Dev Containers connection. The fixture creates real loopback TCP forwarding through workspace.openTunnel, exercising VS Code's forwarding model, configuration resolution, Ports view, and native dialog service. It does not replace those VS Code components.
Reproduction steps
Download the self-contained source fixture. It contains the extension source, initial workspace settings, and README; no dependency installation is needed.
-
Extract the archive. Ensure loopback ports 45321 and 45322 are free. From the extracted directory, launch:
code-insiders --new-window --profile "Require Local Port Repro" --disable-extensions \ --extensionDevelopmentPath="$PWD/extension" \ --enable-proposed-api local-repro.require-local-port-repro \ --skip-welcome --skip-release-notes "$PWD/workspace"
On macOS, if the CLI is not on PATH, use the installed application's
Contents/Resources/app/bin/code. -
Wait more than ten seconds after startup. VS Code's mismatch-dialog cooldown otherwise suppresses even the positive control.
-
Run Repro: Range Rule from the Command Palette. It configures:
"remote.portsAttributes": { "45300-45400": { "label": "Repro range", "requireLocalPort": true } }, "remote.otherPortsAttributes": {}
The fixture opens remote port 45321, requesting local port 45322. A fixture server already occupies 45322. The provider attempts it, receives
EADDRINUSE, chooses another local port, and forwards to the HTTP application. -
Open the Ports view. The row has label Repro range, confirming the range matched. The local port differs from 45322, but no mismatch warning appears.
-
Run Repro: Exact Port Rule. It closes the previous tunnel and replaces the range with the exact key
"45321", keepingrequireLocalPort: true. The same conflict now produces the expected mismatch warning. -
Dismiss the warning, wait more than ten seconds, then run Repro: Exact Port False Control. It uses exact key
"45321"withrequireLocalPort: false; forwarding succeeds without a warning, as expected. -
Close the development host to stop the fixture servers and tunnels.
The fixture also includes optional host-and-port and fallback commands; those were not completed in the recorded desktop run.
Expected and actual results
A matched range with requireLocalPort: true should show the same warning as a matched exact-port rule when the requested local port cannot be used. This setting requests a warning; it does not prohibit forwarding to another port.
| Case | Actual local port in recorded run | Mismatch warning | Verification |
|---|---|---|---|
Range, true |
61303 instead of 45322 | Missing | VS Code desktop |
Exact port, true |
61380 instead of 45322 | Shown | VS Code desktop |
Exact port, false |
61452 instead of 45322 | Absent, as expected | VS Code desktop |
Host-and-port, true |
Not tested in desktop | Resolved flag was undefined |
Source-class harness only |
Process regex, true |
Not tested in desktop | Resolved flag was undefined |
Source-class harness only |
All three desktop forwards returned HTTP 200 with the expected fixture response. The range attempt started over 39 seconds after extension activation; subsequent cases were over a minute apart, avoiding the ten-second cooldown.
Range: matched label, different local port, no warning
Exact-port positive control: warning appears
Exact-port false control: no warning
Root cause
In PortsAttributes.getAttributes, the numeric exact-port branch reads found.requireLocalPort. The branch shared by ranges, regexes, and host-and-port rules instead assigns:
attributes.requireLocalPort = (attributes.requireLocalPort !== undefined) ? attributes.requireLocalPort : undefined;It never reads found.requireLocalPort, so a matching rule cannot supply that value. Other attributes such as the label are merged.
The downstream showPortMismatchModalIfNeeded guard returns early when the flag is absent, explaining the missing dialog.
This conflicts with the configuration schema's documented support for range attributes and the requireLocalPort warning.
The faulty assignment is present in the original feature commit from May 2021; this appears longstanding rather than a recent regression.
Related reports and fixture caveats
I searched issues and PRs in both microsoft/vscode and microsoft/vscode-remote-release and did not find a matching range/regex/host resolution report or fix. remote-release #5125 concerned an exact numeric rule and localhost binding. The original manual test plan #5118 did not cover range rules.
The built-in vscode.tunnel-forwarding extension attempted to register a second provider and reported an activation error. The fixture provider registered first and created all three observed tunnels; the working HTTP forwards and numeric positive control verify the intended path ran. No sign-in or public forwarding was used.
The fixture's case-start.rules/fallback log fields use a pre-update configuration snapshot. For applied settings, inspect the workspace JSON and Ports view labels. Provider results and HTTP events record the actual forward.
Activity
vs-code-engineering commentedon Nov 2, 2026
This bug has been fixed in the latest release of VS Code Insiders!
Anh Dang (@kinqsradio), you can help us out by commenting
/verifiedif things are now working as expected.If things still don't seem right, please ensure you're on version 6771084 of Insiders (today's or later - you can use
Help: Aboutin the command palette to check), and leave a comment letting us know what isn't working as expected.Happy Coding!