Return graceful output from get_stats instead of a 500#1570
Merged
Conversation
get_stats/{id} fataled when the item id was missing and 500'd whenever an
enhanced app's livestats() threw - a broken or updated remote app definition
(e.g. Komga) took the whole request down, and the frontend then stopped
refreshing that tile entirely.
getStats now returns valid JSON (200) with an inactive/empty payload when the
item is missing, has no class, references a stale class, or throws, logging
the failure for diagnosis. The successful path is unchanged and returns the
livestats output verbatim.
Resolves #1558
This was referenced Jul 8, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Resolves #1558.
GET get_stats/{id}returned HTTP 500 when an enhanced app's live-stats rendering failed — the reporter's Komga tile. Two causes:Item::find($id)fataled on a missing id, and$application->livestats()threw whenever a remote app definition was broken/updated or its upstream API returned unexpected data.Because the frontend (
liveStatRefresh.js) stops re-queuing a tile on any non-200 response, a single 500 also permanently killed that tile's live updates until a page reload.The individual app definitions (Komga, etc.) live in a separate remote repo downloaded to
app/SupportedApps/at runtime, so their blades can't be fixed here — but the core endpoint should never 500 on a bad one.Change
ItemController::getStatsnow always returns valid JSON (HTTP 200):{"status":"inactive","html":""}\Throwablefrom config/instantiation/livestats()is caught, logged (id + class + message), and returns the same graceful payloadlivestats()JSON is returned verbatimThe tile renders empty on failure and the refresh loop keeps running, instead of the whole request 500ing.
Tests
tests/Feature/GetStatsTest.php(4 tests): missing id doesn't 500, a throwing app degrades gracefully (the #1558 regression), an item with no class is graceful, and the happy path returns livestats output byte-for-byte. Full suite green;phpcsno new errors.