Skip to content

Commit adba7a7

Browse files
committed
fix(cortex-engine): return ProviderNotFound error for unknown providers
Fixes bounty issue #1297 When a user specifies an unknown provider (e.g., --model invalid/model), the code now returns a clear ProviderNotFound error instead of an ApiKeyNotFound error which was misleading since the issue is the unrecognized provider, not missing authentication.
1 parent 2965e36 commit adba7a7

File tree

1 file changed

+4
-14
lines changed
  • cortex-engine/src/client

1 file changed

+4
-14
lines changed

cortex-engine/src/client/mod.rs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -110,20 +110,10 @@ pub fn create_client(
110110
model.to_string(),
111111
base_url.map(std::string::ToString::to_string),
112112
))),
113-
// For any other provider, try OpenAI-compatible API
114-
_ => {
115-
if api_key.is_empty() {
116-
Err(crate::error::CortexError::ApiKeyNotFound {
117-
provider: provider_id.to_string(),
118-
})
119-
} else {
120-
Ok(Box::new(OpenAiClient::new(
121-
model.to_string(),
122-
api_key.to_string(),
123-
base_url.map(std::string::ToString::to_string),
124-
)))
125-
}
126-
}
113+
// Unknown provider - return clear error
114+
_ => Err(crate::error::CortexError::ProviderNotFound {
115+
provider: provider_id.to_string(),
116+
}),
127117
}
128118
}
129119

0 commit comments

Comments
 (0)