fix: preserve reverse-proxy base path in SSH proxy URL#71
Merged
Conversation
ssh_proxy_url rebuilt the websocket URL from scheme and netloc only, hardcoding an absolute /api/v1 path and discarding any base path. Behind a reverse proxy mounted at e.g. /flowmesh, the prefix was dropped from both the printed ProxyCommand instructions and the live `ssh proxy` backend. Join the base path with the API prefix, consistent with _make_url. Signed-off-by: Noppanat Wadlom <noppanat.wad@gmail.com>
d500467 to
fe57896
Compare
Signed-off-by: Noppanat Wadlom <noppanat.wad@gmail.com>
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.
Purpose
When a FlowMesh server is deployed behind a reverse proxy that mounts it under a base path (e.g. reachable at
example.com:8000/flowmesh), the SSH proxy connection instructions and the live proxy backend built a websocket URL with the base path stripped —wss://example.com:8000/api/v1/ssh/tasks/<id>/proxyinstead ofwss://example.com:8000/flowmesh/api/v1/ssh/tasks/<id>/proxy— soflowmesh ssh connect(and the copy-pastewebsocatcommand fromflowmesh task watch) could not reach the proxy endpoint.Changes
sdk/src/flowmesh/ssh.py—ssh_proxy_urlrebuilt the URL fromurlsplit(base_url)keeping only the scheme and netloc, then hardcoded an absolute/api/v1/ssh/tasks/<id>/proxypath, discardingbase.path. It now joins the configured base path with the API prefix ({base.path.rstrip('/')}{API_VERSION_PREFIX}/ssh/tasks/{task_id}/proxy), mirroring how_make_urlcomposes REST URLs, and reuses theAPI_VERSION_PREFIXconstant instead of re-hardcoding/api/v1. The http→ws / https→wss scheme conversion is unchanged.tests/sdk/test_resource_helpers.py— regression coverage: root-mounted base URL (no double slash), base-path preservation (/flowmesh), http→ws / https→wss conversion, trailing-slash handling, and a proxy-modessh_connection_commandscase asserting the embeddedProxyCommandURL carries the prefix.Design
The single
ssh_proxy_urlhelper feeds both user-visible paths — the printedProxyCommand=websocat …instructions inflowmesh task watchand the liveflowmesh ssh proxybackend used byflowmesh ssh connect— so the one-line fix corrects both.base.path.rstrip('/')yields""for a root-mounted server (preserving the existing/api/v1/...output with no leading double slash) and/flowmeshfor a base-path deployment, including the trailing-slash form.Test Plan
Test Result
pytest tests/ --ignore=tests/worker/test_mp_executor_cleanup_gpu.py— all tests passed.pre-commit run --all-files— black / isort / ruff / codespell pass.Pre-submission Checklist
pre-commit run --all-filesand fixed any issues.uv run pytest tests/passes locally.[BREAKING]and described migration steps above.