Preserve guide data across EPG refresh failures - #182
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Some newly introduced outcome messaging and error-wrapping behavior is misleading or drops important error metadata, which can impair operational diagnosis and client handling.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR improves EPG refresh resiliency by retaining last-known-good XMLTV per source when a fetch/read fails, and by surfacing explicit refresh outcomes (ok, degraded, failed) through the scheduler, HTTP reload endpoint, and MCP tool.
Changes:
- Serialize concurrent EPG refresh requests and return a structured refresh outcome from
refreshEPG(). - Retain and reuse last-good per-source XMLTV data to keep guide output available during transient source failures, and remove the module-owned periodic interval in favor of the scheduler job.
- Expand integration coverage to validate stale fallback, recovery, and all-source failure behavior.
File summaries
| File | Description |
|---|---|
| test/integration/guide.test.js | Adds integration coverage for stale fallback, recovery, and full failure outcomes. |
| server/epg.js | Implements serialized refresh orchestration, per-source last-good retention, and refresh outcome reporting. |
| server/scheduler.js | Treats failed refresh outcomes as job failures while allowing degraded runs to succeed. |
| server/mcp.js | Returns explicit MCP error on failed outcome and includes outcome details in reload_epg responses. |
| server/config.js | Updates /api/reload/epg to return outcome status and per-source results to callers. |
Review details
Suppressed comments (1)
server/epg.js:430
- Wrapping the Axios error in a new Error drops Axios-specific fields (e.g., err.code / err.response.status), so the downstream catch block’s actionable logging branches won’t run when there is no last-known-good fallback.
} catch (httpErr) {
sourceFetchError = new Error(`Failed to fetch EPG: ${httpErr.message}`);
const lastGood = lastGoodSourceXml.get(sourceName);
if (!lastGood || lastGood.url !== sourceUrl) {
throw sourceFetchError;
}
- Files reviewed: 5/5 changed files
- Comments generated: 4
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+290
to
+293
| res.status(outcome.status === 'degraded' ? 207 : 200).json({ | ||
| status: outcome.status, | ||
| sources: outcome.sourceResults, | ||
| }); |
Comment on lines
409
to
+414
| } catch (fileErr) { | ||
| throw new Error(`Failed to read file: ${fileErr.message}`); | ||
| sourceFetchError = new Error(`Failed to read file: ${fileErr.message}`); | ||
| const lastGood = lastGoodSourceXml.get(sourceName); | ||
| if (!lastGood || lastGood.url !== sourceUrl) { | ||
| throw sourceFetchError; | ||
| } |
Comment on lines
+614
to
+616
| const message = epgSources.length | ||
| ? 'All configured EPG sources failed; retained the previous guide.' | ||
| : 'No EPG sources are configured.'; |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
4 tasks
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.
Summary
Validation