Bug Report
Version: cortex v0.0.7
Command: cortex models list --sort context and cortex models list --sort created
Description
cortex models list validates sort values against VALID_SORT_VALUES = ["name", "provider", "context", "created", "id"], so --sort context and --sort created are accepted without error. However, these values are not handled in ModelSortOrder::from_str(), causing them to silently fall back to the default sort (--sort id).
Steps to Reproduce
# Invalid value correctly rejected:
$ cortex models list --sort invalid
Error: Invalid sort value 'invalid'. Valid values are: name, provider, context, created, id
# Valid value accepted but ignored (same output as --sort id):
$ cortex models list --sort context
Available Models:
anthropic (4 models)
claude-3-5-haiku-20241022
claude-3-5-sonnet-20241022
...
$ cortex models list --sort id
Available Models:
anthropic (4 models)
claude-3-5-haiku-20241022 <- identical ordering
claude-3-5-sonnet-20241022
...
Expected Behavior
--sort context should sort models by context window size.
--sort created should sort models by creation date.
Or if unimplemented, they should be removed from VALID_SORT_VALUES and return an error.
Actual Behavior
context and created are accepted as valid but produce identical output to --sort id (alphabetical by model ID).
Screenshot (real binary output)

Root Cause
In src/cortex-cli/src/models_cmd.rs:
VALID_SORT_VALUES (line 426) includes "context" and "created":
const VALID_SORT_VALUES: &[&str] = &["name", "provider", "context", "created", "id"];
But ModelSortOrder::from_str() (line 46) only handles id, name, and provider:
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.to_lowercase().as_str() {
"id" => Ok(Self::Id),
"name" => Ok(Self::Name),
"provider" => Ok(Self::Provider),
_ => Err(format!("Invalid sort order '{}'. ...", s)),
}
}
Line 438 then silently swallows the parse error:
let sort_order: ModelSortOrder = sort_by.parse().unwrap_or_default();
// unwrap_or_default() -> ModelSortOrder::Id (the default variant)
File: src/cortex-cli/src/models_cmd.rs, lines 33-55 and 426-438
Bug Report
Version: cortex v0.0.7
Command:
cortex models list --sort contextandcortex models list --sort createdDescription
cortex models listvalidates sort values againstVALID_SORT_VALUES = ["name", "provider", "context", "created", "id"], so--sort contextand--sort createdare accepted without error. However, these values are not handled inModelSortOrder::from_str(), causing them to silently fall back to the default sort (--sort id).Steps to Reproduce
Expected Behavior
--sort contextshould sort models by context window size.--sort createdshould sort models by creation date.Or if unimplemented, they should be removed from
VALID_SORT_VALUESand return an error.Actual Behavior
contextandcreatedare accepted as valid but produce identical output to--sort id(alphabetical by model ID).Screenshot (real binary output)
Root Cause
In
src/cortex-cli/src/models_cmd.rs:VALID_SORT_VALUES(line 426) includes"context"and"created":But
ModelSortOrder::from_str()(line 46) only handlesid,name, andprovider:Line 438 then silently swallows the parse error:
File:
src/cortex-cli/src/models_cmd.rs, lines 33-55 and 426-438