fix(secure-gateway): align weights proxy builder with wrap_url (#2662) - #2748
Open
arthi-arumugam-git wants to merge 1 commit into
Open
Conversation
roboflow_secure_gateway_proxy_url_builder diverged from wrap_url in two ways, both reported in roboflow#2662: - No idempotence guard, so an already-wrapped download_url was proxied again: {gateway}/proxy?url={gateway}%2Fproxy%3Furl%3D... wrap_url gained this guard in roboflow#2658 and the weights builder did not. - The gateway base path was dropped. urlsplit scheme+netloc discards any path, so SECURE_GATEWAY=https://gw.local/edge sent weights traffic to gw.local/proxy while server traffic went to gw.local/edge/proxy. Neither failure raises: weights are simply fetched from somewhere other than the configured gateway. The two packages cannot share an implementation without a dependency between them, so parity is pinned by a cross-package test in the inference unit suite, where inference_models is already installed.
arthi-arumugam-git
requested review from
PawelPeczek-Roboflow,
dkosowski87,
grzegorz-roboflow,
hansent,
probicheaux,
rafel-roboflow and
yeldarby
as code owners
August 3, 2026 03:53
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.
Closes the first half of #2662.
roboflow_secure_gateway_proxy_url_builderandwrap_urlimplement the same/proxy?url=contract, one for weights traffic and one for server traffic. They haddrifted apart in two ways, both exactly as @alexnorell described:
1. No idempotence guard. An already-wrapped
download_urlwas wrapped again. Onmain:wrap_urlgained this guard in #2658; the weights builder did not.2. The gateway base path was dropped. The builder took
urlsplitscheme and netloconly, so
SECURE_GATEWAY=https://gw.local/edgesent weights traffic togw.local/proxywhile server traffic went to
gw.local/edge/proxy.Neither one raises. The weights are simply fetched from somewhere other than the gateway
you configured, which is the failure mode a secure gateway exists to prevent.
The fix
The builder now mirrors
wrap_urlline for line:rstrip("/")on the configured value sothe base path survives, then the same
gateway_prefixconstruction and the samestartswithguard.The two fixes interact, which is worth stating because it is the part that is easy to get
wrong. The idempotence guard has to compare against a prefix that already includes the base
path, otherwise fixing the path reintroduces double-wrapping under
/edge. There is a testfor that case specifically.
Tests
Four in
inference_models/tests/unit_tests/weights_providers/test_roboflow.py:idempotence, base path preserved, base path with a trailing slash, and idempotence under a
base path. All four fail on
main.One parametrized cross-package test in
tests/inference/unit_tests/core/utils/test_url_utils.pyasserting the two wrappers produce byte-identical output across six gateway spellings, and
that both are idempotent. Six cases, all failing on
main, including the plaingateway.localcase because the idempotence half diverged for every spelling.The issue suggested either sharing one implementation or keeping them behaviour-identical
with cross-package tests. Sharing would mean a dependency between the two packages, so this
takes the second option. The parity test lives in the
inferenceunit suite rather than theinference_modelsone because that workflow already doespip install --no-deps ./inference_models, so both are importable there, whereas theinference_modelssuite runswith
working-directory: inference_models. It is guarded withimportorskipregardless.Not in scope
Part 2 of #2662, the per-run
step_execution_modebypass, is untouched. That one needsgateway support in
inference_sdk'sInferenceHTTPClientor a guard at theStepExecutionModeconsumption point, and it is a design decision rather than a divergencebetween two functions.
Verification
test_url_utils.py: 12 passed with the fix, 6 failed and 6 passed without it.test_roboflow.py(weights providers): 72 passed with the fix, 68 passed without it plusthe 4 new failures.
test_roboflow_api.pyis byte-identical before and after, so nothingthat routes through these wrappers changed behaviour.
blackandisortclean per thestyletarget.