From 25e95a7366265ffc809b34ca876229ae01cc8d5b Mon Sep 17 00:00:00 2001 From: nesquena-hermes <[email protected]> Date: Tue, 2 Jun 2026 20:49:29 +0000 Subject: [PATCH] =?UTF-8?q?fix(ui):=20#3429=20round-2=20=E2=80=94=20never?= =?UTF-8?q?=20fall=20back=20to=20authority=20or=20placeholder=20(Codex=20M?= =?UTF-8?q?UST-FIX)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Codex re-check: degenerate URIs still leaked — gpt://folder123 returned the authority, gpt://folder123/${MODEL} returned the placeholder. Removed the _all[0] authority fallback and guarded the literal-last-path fallback against placeholders; a URI with no usable model segment now falls back to the raw id. Added regression cases for gpt://folder123 and gpt://folder123/${MODEL}. --- static/ui.js | 9 ++++++--- tests/test_issue3429_uri_scheme_model_label.py | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/static/ui.js b/static/ui.js index 787b0ae1d..962d9247d 100644 --- a/static/ui.js +++ b/static/ui.js @@ -2930,9 +2930,12 @@ function getModelLabel(modelId){ if (!_lastUsable) _lastUsable = _seg; if (!_isVersionTail(_seg)) { _pick = _seg; break; } } - // Fallbacks: last non-placeholder path segment, else the literal last path - // segment, else the authority, else the raw id. Never an env-var placeholder. - _last = _pick || _lastUsable || _path[_path.length - 1] || _all[0] || modelId; + // Fallbacks: the chosen non-version segment, else the last non-placeholder + // path segment. NEVER the authority and NEVER a `${...}` placeholder — for + // a degenerate id (`gpt://folder123`, `gpt://folder123/${MODEL}`) fall all + // the way back to the raw id rather than leak the folder/host or env var. + const _lastPath = _path[_path.length - 1] || ''; + _last = _pick || _lastUsable || (_lastPath && !_isPlaceholder(_lastPath) ? _lastPath : '') || modelId; } else { _last = modelId.includes('/') ? (modelId.slice(modelId.indexOf('/')+1) || modelId) : modelId; } diff --git a/tests/test_issue3429_uri_scheme_model_label.py b/tests/test_issue3429_uri_scheme_model_label.py index 614356a61..a8228d9b9 100644 --- a/tests/test_issue3429_uri_scheme_model_label.py +++ b/tests/test_issue3429_uri_scheme_model_label.py @@ -88,6 +88,20 @@ def test_uri_label_edge_cases_never_return_authority_or_drop_digit_models(): assert label != "folder123", "authority/folder leaked into label" +def test_uri_degenerate_ids_fall_back_to_raw_not_authority_or_placeholder(): + """#3429 follow-up 2 (Codex gate): a URI with no usable model segment must + fall back to the raw id — never the authority/folder, never a ${...} env-var.""" + out = _labels([ + "gpt://folder123", # authority only, no path + "gpt://folder123/${MODEL}", # path is only an env-var placeholder + ]) + assert out["gpt://folder123"] == "gpt://folder123" + assert out["gpt://folder123/${MODEL}"] == "gpt://folder123/${MODEL}" + for label in out.values(): + assert label != "folder123", "authority leaked into label" + assert label not in ("${MODEL}",), "env-var placeholder leaked into label" + + def test_uri_fix_does_not_regress_multi_slash_or_bare_ids(): """#3360 multi-slash hierarchy + single-slash/bare ids stay correct.""" out = _labels([