# ollama: Don't abort entire model fetch if one model's details fail to load \(\#59606\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/4eb039b451fd907a7486c030df62cd9d76b12357)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 4eb039b451fd907a7486c030df62cd9d76b12357

Requested commit: 4eb039b451fd907a7486c030df62cd9d76b12357

Commit: 4eb039b451fd907a7486c030df62cd9d76b12357

Tree: 4217ebfc8aa4b4875a56eb5b00a243c1134cbea9

Author: Manoj Mishra

Committer: GitHub

## Message

```
ollama: Don't abort entire model fetch if one model's details fail to load (#59606)

## Summary

Fixes #37815.

`State::fetch_models()` calls `/api/tags` to list models, then calls
`/api/show` for **every** model in that list to get its capabilities,
collecting the results with `collect::<Result<Vec<_>>>()?`. If
`/api/show` errors for even one model, the whole batch fails and
`fetched_models` is never populated. Since `is_authenticated()` is
defined as `!self.fetched_models.is_empty()`, this means a single bad
model permanently breaks both authentication state and the model picker
for the entire Ollama provider - with no error surfaced anywhere (not
the UI, not the logs), which matches the reports in #37815 of "Connect
does nothing" / "no logs, no nothing".

I hit this myself: I had a stale local reference to an Ollama Cloud
model that had been retired server-side. `/api/show` for that one model
returned `410 Gone`, which silently broke Connect and the model picker
for every other model too. Removing the retired model with `ollama rm`
fixed it immediately, which confirmed the root cause.

## Fix

Instead of aborting the whole fetch on the first error, skip individual
models that fail `/api/show` and log a warning, keeping the rest.
Extracted this into a small `skip_failed_models` helper so it's
unit-testable without mocking HTTP.

## Disclosure

I used Claude (Anthropic's Claude Code) to help track down this root
cause (tracing through `fetch_models`/`is_authenticated` in this file)
and draft the fix + tests below. I reviewed and understand the change -
it's a small, targeted fix to a single function plus two unit tests for
the new helper.

## Test plan

- [x] `cargo check -p language_models` passes
- [x] `cargo test -p language_models --lib ollama::` - all 3 tests pass
(the 2 new ones plus the existing
`test_merge_settings_preserves_display_names_for_similar_models`,
unaffected by this change)
- [x] `cargo fmt -p language_models -- --check` - no diff

## Release Notes

Release Notes:

- Fixed Ollama models silently failing to show up in the model picker
(and "Connect" appearing to do nothing) when a single model's details
couldn't be fetched, e.g. a retired Ollama Cloud model

---------

Co-authored-by: MrSubidubi <finn@zed.dev>
Co-authored-by: Ben Brandt <benjamin.j.brandt@gmail.com>
```

## Parents

- [cf76418cf4f1eec5d91e416d35b76b7af53e17e5](https://git.cafe/gitcafe/zed/commit/cf76418cf4f1eec5d91e416d35b76b7af53e17e5?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/4eb039b451fd907a7486c030df62cd9d76b12357?format=markdown)
