Skip to content

fix: guard _resolve_proxy against bare-port inputs#9366

Merged
mscolnick merged 1 commit into
mainfrom
ms/port-proxy-fixes
Apr 24, 2026
Merged

fix: guard _resolve_proxy against bare-port inputs#9366
mscolnick merged 1 commit into
mainfrom
ms/port-proxy-fixes

Conversation

@mscolnick

Copy link
Copy Markdown
Contributor

_resolve_proxy(..., ":8080") previously returned (8080, ":8080") because parsed.hostname is empty for a bare-port netloc and we fell back to the raw proxy string — so ":8080" became the public host.

Fall back to the inbound host arg when parsed.hostname is empty.

`_resolve_proxy(..., ":8080")` previously returned `(8080, ":8080")`
because `parsed.hostname` is empty for a bare-port netloc and we fell
back to the raw proxy string — so `":8080"` became the public host.

Fall back to the inbound `host` arg when `parsed.hostname` is empty.
Copilot AI review requested due to automatic review settings April 24, 2026 17:02
@vercel

vercel Bot commented Apr 24, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment Apr 24, 2026 5:02pm

Request Review

@dmadisetti dmadisetti added the bug Something isn't working label Apr 24, 2026

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.

Pull request overview

Fixes _resolve_proxy so that bare-port proxy inputs (e.g. ":8080") don’t incorrectly become the public hostname, by falling back to the inbound host when urlparse(...).hostname is empty.

Changes:

  • Update _resolve_proxy to use the inbound host when parsed.hostname is empty (bare-port proxy case).
  • Add regression coverage for ":8080" and for empty-string proxy behavior.

Reviewed changes

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

File Description
marimo/_server/start.py Adjusts proxy parsing to avoid treating ":8080" as an external hostname; falls back to inbound host.
tests/_server/test_startup_url.py Adds parametrized test cases covering bare-port proxy and empty-string proxy inputs.

@cubic-dev-ai cubic-dev-ai Bot 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.

No issues found across 2 files

Architecture diagram
sequenceDiagram
    participant Main as Server Startup
    participant Resolver as _resolve_proxy()
    participant Parser as urlparse (Stdlib)

    Note over Main,Parser: Determine public-facing Host/Port

    Main->>Resolver: resolve(port, host, proxy_string)
    
    opt proxy_string is not None
        Resolver->>Parser: Parse proxy_string
        Parser-->>Resolver: Parsed (hostname, port, scheme)
        
        Resolver->>Resolver: Extract hostname from Parser
        
        alt NEW: Hostname is empty (e.g. ":8080")
            Resolver->>Resolver: CHANGED: Fallback to inbound 'host' argument
        else Hostname found
            Resolver->>Resolver: Use parsed hostname
        end

        alt Port is explicitly in proxy
            Resolver->>Resolver: Use parsed port
        else Proxy is HTTPS
            Resolver->>Resolver: Use port 443
        else Proxy is HTTP
            Resolver->>Resolver: Use port 80
        end
    end

    Resolver-->>Main: Return (external_port, external_host)
    Note over Main: Server starts using resolved identity
Loading

@mscolnick mscolnick merged commit b659cd8 into main Apr 24, 2026
39 of 50 checks passed
@mscolnick mscolnick deleted the ms/port-proxy-fixes branch April 24, 2026 17:27
@github-actions

Copy link
Copy Markdown

🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.23.3-dev48

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants