catalog: accept OpenRouter's tilde-prefixed floating aliases

`valid_catalog_model_id` whitelisted only ASCII alphanumerics plus `. _ : / -`,
so every OpenRouter id of the form `~vendor/model-latest` failed the id check in
`record_success_for_identity`, which rejects the whole delta as `invalid_response`.
The CLI surface reported `cache_write_failed`, and the durable openrouter scope
stayed at 0 rows: 468 live models were dropped because 19 of them use a `~`
prefix.

Measured just now against https://openrouter.ai/api/v1/models (468 rows):
19 rejections, all `~`-prefixed floating aliases such as
`~anthropic/claude-sonnet-latest` and `~openai/gpt-sol-latest`. models.dev
(230 providers) and OrcaRouter (172 ids) produce zero rejections, so `~` is the
only real charset gap. `~` carries no path, whitespace, quoting or control
character risk, and `valid_catalog_model_id` still requires an alphanumeric
byte and caps length at 256.

Reproduced with the installed binary before the change:
`models --update --provider openrouter --json` -> failed / cache_write_failed,
status.reason invalid_response, model_count 0.

Verification: release build stamped at this commit, then the same command must
report updated with a non-empty roster, and the full `models --update` must keep
the other providers green.
This commit is contained in:
CodeWhale Bot committed 2026-10-23 10:05:26 -07:00
1 parent 35fb7fbb53
commit 587b04cfff
1 file changed
+1 -1
+1 -1
View File
@@ -1532,7 +1532,7 @@ pub(crate) fn valid_catalog_model_id(value: &str) -> bool {
&& value.len() <= 256
&& value.bytes().any(|byte| byte.is_ascii_alphanumeric())
&& value.bytes().all(|byte| {
byte.is_ascii_alphanumeric() || matches!(byte, b'.' | b'_' | b':' | b'/' | b'-')
byte.is_ascii_alphanumeric() || matches!(byte, b'.' | b'_' | b':' | b'/' | b'-' | b'~')
})
}