Skip to content

remote.portsAttributes: exact-port label clears HTTPS protocol inherited from a range #344750

Closed

Description

@kinqsradio

A label-only exact-port rule in remote.portsAttributes clears HTTPS inherited from a matching range. The Ports view and forwarded URI consequently fall back to HTTP.

Reproduction

  1. Configure:
    {
        "remote.portsAttributes": {
            "3500": { "label": "Application" },
            "3000-4000": { "protocol": "https" }
        }
    }
  2. Forward localhost:3500 through a tunnel provider without explicitly overriding the protocol.
  3. Open the port's context menu → Change Port Protocol.

Expected: HTTPS remains selected with the Application label.
Actual: HTTP is selected; the resolved protocol is undefined.

Workaround: Add "protocol": "https" to the exact-port rule or remove that rule. Reversing the configuration entries does not help.

Screenshot and environment

Captured from native Code - OSS built from unmodified main, version 1.145.0, commit 915c6faed9c93b3c05bd9aa37ba0b1358103bdf1, on macOS 26.2 arm64 (Node 24.22.1, Electron 43.8.3). This source version is newer than the 1.143.1 stable release mentioned by the bot.

Unmodified source: HTTPS range with a label-only exact-port rule incorrectly selects HTTP

Extensions disabled: Core service tests reproduce the failure without extensions. For the screenshot, installed extensions were disabled; one local fixture supplied a tunnel provider and enabled the real Ports view. It uses the real configuration/merge/tunnel paths and does not force the protocol.

Diagnosis and scope

PortsAttributes.getAttributes unconditionally assigns attributes.protocol = found.protocol for an exact-port rule. The range runs first, then the label-only rule erases its protocol. A range starting at 3500 instead survives because of tied sort ordering.

The source-built client and core regression assertions confirm the failure. Native verification covers protocol selection with a controlled local provider; no TLS exchange or SSH/Dev Containers/cloud connection was tested. The client-only build did not compile every built-in extension.

This is separate from #344184 and predates its fix #344185.

Activity

  1. vs-code-engineering commented on Oct 28, 2026

    @vs-code-engineering
    Contributor

    Thanks for creating this issue! It looks like you may be using an old version of VS Code; the latest stable release is 1.143.1. Please try upgrading to the latest version and checking whether this issue remains.

    Happy Coding!

  2. ayushkrsingh946 commented on Oct 28, 2026

    @ayushkrsingh946
    Contributor

    Hi Anh Dang (@kinqsradio) Alex Ross (@alexr00)! I'd like to work on this issue. Could you please assign this to me?

    Analysis

    In PortsAttributes.getAttributes (src/vs/workbench/services/remote/common/tunnelModel.ts), when merging attributes for an exact-port match (found.key === port), protocol is assigned unconditionally:

    attributes.protocol = found.protocol;

    Because sortAttributes orders ranges by start port and exact rules by port, a range such as 3000-4000 with protocol: 'https' runs first and sets attributes.protocol = 'https'. When the exact-port rule 3500: { label: 'Application' } is evaluated next, its undefined protocol clears the previously inherited protocol back to undefined.

    Plan

    1. Update attributes.protocol assignment in the exact-port branch of PortsAttributes.getAttributes to preserve inherited values when omitted:
    attributes.protocol = found.protocol ?? attributes.protocol;
    1. Add regression tests in tunnelModel.test.ts verifying:
      • Range protocol is preserved when an exact-port rule only defines a label.
      • Exact-port rule explicitly specifying a protocol overrides range and regex rules.
    2. Run the unit test suite and typechecks to verify.
  3. kinqsradio commented on Oct 28, 2026

    @kinqsradio
    ContributorAuthor

    I already opened #344764 for this issue. #344775 appears to duplicate the same fix.

  4. ayushkrsingh946 commented on Oct 28, 2026

    @ayushkrsingh946
    Contributor
  5. added
    bug
    on Oct 29, 2026
  6. added this to the 1.145.0 milestone on Oct 29, 2026
  7. added
    unreleased
    on Oct 29, 2026
  8. vs-code-engineering commented on Oct 29, 2026

    @vs-code-engineering
    Contributor

    Sharing media and context from merged PR #344764 for verification:

    A label-only exact-port rule currently erases HTTPS inherited from an overlapping range, making the forwarded URI and Ports view fall back to HTTP. Preserve the accumulated protocol when the exact rule omits it; explicit HTTP/HTTPS overrides retain precedence. This also prevents an empty exact rule from incorrectly activating remote.otherPortsAttributes.

    Five regression tests cover HTTP/HTTPS inheritance, ranges starting below or at the exact port, explicit overrides, and empty/undefined-rule fallback interactions.

    Validation

    • 33 passing across tunnelModel, browserRemoteResourceHandler, remoteExplorer and urlFinder browser suites. Two new regression tests fail against the original code.
    • Targeted ESLint and git diff --check pass.
    • Native source-built Code - OSS 1.145.0 on macOS arm64: the real Ports view changes from HTTP to HTTPS with the same configuration; the local tunnel provider receives protocol: "https" after the fix.

    Before — unmodified source:

    Unmodified source incorrectly selects HTTP

    After — fixed source:

    Fixed source preserves HTTPS

    Checks ran on base 915c6faed9c9, before rebasing onto 959f45119fbe; affected files and dependencies were unchanged and checks were not rerun. Native verification used a controlled local provider, without a TLS exchange or SSH/Dev Containers/cloud connection. Full distribution build, full suite and broad typecheck were not run.

    Source PR: #344764

  9. added
    insiders-released
    and removed
    unreleased
    on Oct 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

buginsiders-releasedverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions