LocalAI icon indicating copy to clipboard operation
LocalAI copied to clipboard

Add-on library: one failing source empties the whole list

Open mudler-agent opened this issue 1 week ago • 1 comments

Describe the bug

When one add-on library source fails to refresh, the whole add-on library is empty and the add-on endpoint answers 503, even if every other source loaded fine. In #13296 the official source failed (a refused redirect, fixed in #13341) and the user lost the library entirely; a user-added source that is down or misconfigured can do the same to the official one.

Cause

Catalog.List in core/services/addons/catalog/catalog.go loops over the sources and returns ErrRefresh for the whole page as soon as the cache of one source is marked failed:

cache, ok := s.cache[id]
if !ok { return Page{}, ErrUnavailable }
if cache.failed { return Page{}, ErrRefresh }

A source with no cache entry yet returns ErrUnavailable the same way. The lookups of one release and of the files of one release do the same per source, which is right there because they name one source.

To Reproduce

  1. Add a library source with a URL that fails (404, a refused redirect, a timeout).
  2. Open the add-on library, or call the add-on catalog endpoint without a source filter.
  3. Entries of the working sources are missing, and the answer is the refresh error.

Expected behavior

The list returns the entries of every source that loaded. A failing source is reported on its own (its error and the time of the last good refresh) and the UI shows it on that source's row, with the other sources still usable. Only a request for the failing source itself (a source filter, one release) answers with the refresh error.

Notes

  • Keep a source's last good entries when a refresh fails, if the cache can hold them, and mark them stale instead of dropping them.
  • The log line added in #13341 already names the cause of a failed refresh; the same text can go to the per-source status.
  • Related: #13296, #13341, #13342.

mudler-agent avatar Nov 20 '26 14:11 mudler-agent

The current master already does most of this: Catalog.List/Search collects each failed source into Page.Failed ({sourceId, name, error, lastSuccess}) and keeps listing every source that loaded — only a request naming the failed source (sourceId filter, Resolve, Releases) answers ErrRefresh/ErrUnavailable, exactly the split proposed here. catalog-search without a sourceId no longer 503s on one bad library.

On the "keep last good entries and mark them stale" note — I looked at implementing it and it conflicts with two things already on master: the catalog suite asserts that a failed source's entries are not served because "a listed entry must be installable", and Resolve/Releases return the refresh error for a failed source (which the issue itself calls correct, since those requests name one source). Serving stale entries would list add-ons that cannot be installed. If you'd rather have stale-listed + stale-resolvable end to end, that's a bigger contract change and I'm happy to write it — otherwise this issue looks closeable.

Written by Devin

sanketpatel32 avatar Nov 24 '26 15:11 sanketpatel32