harden #5979 per Codex gate: union extra_models bucket + profile-isolation fail-safe
Codex regression gate found two real issues on the first cut: 1. extra_models bucket: a provider's advertised ids can be split across the catalog's 'models' (visible) and 'extra_models' (picker overflow) buckets. Reading only 'models' could miss a bare id that overflowed, leaving the #433 stale prefix unstripped. _endpoint_advertised_model_ids now unions both buckets. 2. Profile isolation (profiles are islands): _available_models_cache is a process global, so a concurrently-active foreign profile could publish the snapshot a different profile then reads for provenance — potentially stripping an advertised full id against another profile's catalog. The accessor now rejects the snapshot unless its published source fingerprint (whose config_yaml axis is the profile-specific config path) matches the current runtime fingerprint; any mismatch fails safe to verbatim preserve. Adds tests: extra_models-counts-as-advertised (#433 via overflow bucket) and foreign-profile-catalog-preserves-verbatim (isolation fail-safe). Test helpers now stamp the source fingerprint exactly as the real publish sites do.
This commit is contained in:
1 parent
4349ff4302
commit
0bdf555779
3 files changed
+87
-1
No files matched your search
@@ -156,6 +156,7 @@ class TestCustomEndpointModelStripping:
|
||||
old_cfg = dict(_api_config.cfg)
|
||||
old_cache = _api_config._available_models_cache
|
||||
old_memo = _api_config._advertised_model_ids_memo
|
||||
old_fp = _api_config._available_models_cache_source_fingerprint
|
||||
model_cfg = {}
|
||||
if provider:
|
||||
model_cfg['provider'] = provider
|
||||
@@ -171,6 +172,7 @@ class TestCustomEndpointModelStripping:
|
||||
'models': [{'id': mid, 'label': mid} for mid in advertised_ids],
|
||||
}]
|
||||
}
|
||||
_api_config._available_models_cache_source_fingerprint = _api_config._models_cache_source_fingerprint()
|
||||
_api_config._advertised_model_ids_memo = None
|
||||
try:
|
||||
return _api_config.resolve_model_provider(model_id)
|
||||
@@ -179,6 +181,7 @@ class TestCustomEndpointModelStripping:
|
||||
_api_config.cfg.update(old_cfg)
|
||||
_api_config._available_models_cache = old_cache
|
||||
_api_config._advertised_model_ids_memo = old_memo
|
||||
_api_config._available_models_cache_source_fingerprint = old_fp
|
||||
|
||||
def test_prefixed_model_stripped_for_custom_endpoint(self):
|
||||
"""Issue #433: 'openai/gpt-5.4' with custom base_url returns bare 'gpt-5.4'
|
||||
|
||||
Reference in new issue
Block a user