fix: remove Option from model listing return types, propagate errors (#7074)

Signed-off-by: Adrian Cole <adrian@tetrate.io>
This commit is contained in:
Adrian Cole
2026-02-09 08:03:10 +08:00
committed by GitHub
parent 4e87011981
commit 08b89ca66b
27 changed files with 177 additions and 218 deletions
+7 -6
View File
@@ -495,7 +495,7 @@ impl Provider for GithubCopilotProvider {
stream_openai_compat(response, log)
}
async fn fetch_supported_models(&self) -> Result<Option<Vec<String>>, ProviderError> {
async fn fetch_supported_models(&self) -> Result<Vec<String>, ProviderError> {
let (endpoint, token) = self.get_api_info().await?;
let url = format!("{}/models", endpoint);
@@ -515,10 +515,11 @@ impl Provider for GithubCopilotProvider {
let json: serde_json::Value = response.json().await?;
let arr = match json.get("data").and_then(|v| v.as_array()) {
Some(arr) => arr,
None => return Ok(None),
};
let arr = json.get("data").and_then(|v| v.as_array()).ok_or_else(|| {
ProviderError::RequestFailed(
"Missing 'data' array in GitHub Copilot models response".to_string(),
)
})?;
let mut models: Vec<String> = arr
.iter()
.filter_map(|m| {
@@ -532,7 +533,7 @@ impl Provider for GithubCopilotProvider {
})
.collect();
models.sort();
Ok(Some(models))
Ok(models)
}
async fn configure_oauth(&self) -> Result<(), ProviderError> {