Skip to content

fix(home): handle GitHub API failures gracefully in releases/changelogs#3292

Merged
PierreBrisorgueil merged 3 commits into
masterfrom
fix/home-github-graceful
Mar 24, 2026
Merged

fix(home): handle GitHub API failures gracefully in releases/changelogs#3292
PierreBrisorgueil merged 3 commits into
masterfrom
fix/home-github-graceful

Conversation

@PierreBrisorgueil

@PierreBrisorgueil PierreBrisorgueil commented Mar 24, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Wrap releases() and changelogs() GitHub API calls in try/catch
  • Return empty array on failure instead of crashing with 422
  • Fixes auth.authorization.integration.tests.js failures when GitHub API is rate-limited

Closes #3291

Summary by CodeRabbit

  • Bug Fixes

    • Improved error handling for releases and changelogs so failures return empty results instead of causing errors.
    • Corrected changelog title mapping to display the proper repository title.
  • Tests

    • Updated integration tests to expect successful HTTP 200 responses with an empty data array for GitHub API failure cases.

…gs (#3291)

Wrap GitHub API calls in try/catch and return empty array on failure.
Prevents 422 errors when rate-limited or repos are unreachable.
Copilot AI review requested due to automatic review settings March 24, 2026 20:02
@coderabbitai

coderabbitai Bot commented Mar 24, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@PierreBrisorgueil has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 13 minutes and 57 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 76ed6994-0c77-4781-b96b-47309f32cdcd

📥 Commits

Reviewing files that changed from the base of the PR and between 2803e5f and 836102e.

📒 Files selected for processing (1)
  • modules/home/services/home.service.js

Walkthrough

Added try/catch error handling to releases() and changelogs() to return empty arrays on GitHub API failures; changelogs() now uses the filtered repo title (repos[i].title). Integration tests updated to expect successful responses with empty data for those failure cases.

Changes

Cohort / File(s) Summary
Home service
modules/home/services/home.service.js
Wrapped GitHub API aggregation (axios.all/mapping) in releases() and changelogs() with try/catch to return [] on error; changelogs() uses repos[i].title when mapping titles.
Integration tests
modules/home/tests/home.integration.tests.js
Updated tests for GitHub API failure scenarios to expect HTTP 200 success responses with a message and empty data arrays for releases and changelogs instead of HTTP 422 errors.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The description covers the core changes and linked issue but is incomplete compared to the template, missing validation checklist, guardrails check, and scope details. Expand description to include all template sections: complete validation checklist, guardrails check, scope analysis, and infra details as applicable.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: handling GitHub API failures gracefully in releases/changelogs functions.
Linked Issues check ✅ Passed All coding requirements from issue #3291 are met: GitHub API calls wrapped in try/catch and empty arrays returned on failure in releases/changelogs.
Out of Scope Changes check ✅ Passed All changes are scoped to the stated objectives: only releases/changelogs error handling in home.service.js and corresponding test updates are modified.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/home-github-graceful

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR makes the Home module’s GitHub-backed informational endpoints (releases() and changelogs()) degrade gracefully when the GitHub API is unavailable (e.g., rate-limited), preventing 422 responses for non-critical data.

Changes:

  • Wrap GitHub API calls in releases() and changelogs() with try/catch and return [] on failure.
  • Simplify async returns by returning arrays directly (instead of Promise.resolve(...)).
  • Fix changelog title mapping to use the filtered repos list when building results.

Comment thread modules/home/services/home.service.js
Comment thread modules/home/services/home.service.js

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
modules/home/services/home.service.js (1)

30-33: 🛠️ Refactor suggestion | 🟠 Major

Update JSDoc tags to @returns on modified async functions.

releases and changelogs were modified, but their headers still use @return instead of @returns. Please align both blocks with the repository JSDoc rule.

✍️ Proposed doc fix
 /**
- * `@desc` Function to get all versions
- * `@return` {Promise} All versions
+ * `@desc` Get all repository releases.
+ * `@returns` {Promise<Array<{title: string, list: Array<{name: string, prerelease: boolean, published_at: string}>}>>}
  */
 const releases = async () => {
 /**
- * `@desc` Function to get all changelogs
- * `@return` {Promise} All changelogs
+ * `@desc` Get all repository changelogs.
+ * `@returns` {Promise<Array<{title: string, markdown: string}>>}
  */
 const changelogs = async () => {

As per coding guidelines, every modified JS function must include JSDoc with @returns (and @param for each argument when present).

Also applies to: 56-59

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@modules/home/services/home.service.js` around lines 30 - 33, Update the JSDoc
blocks for the modified async functions `releases` and `changelogs` to use the
correct `@returns` tag instead of `@return`; also ensure any function parameters
are documented with `@param` entries if those functions accept arguments (match
existing repository JSDoc style and wording). Locate the JSDoc comments
immediately above the `releases` and `changelogs` function definitions and
replace `@return` with `@returns` and add missing `@param` lines where
applicable.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@modules/home/services/home.service.js`:
- Around line 30-33: Update the JSDoc blocks for the modified async functions
`releases` and `changelogs` to use the correct `@returns` tag instead of
`@return`; also ensure any function parameters are documented with `@param`
entries if those functions accept arguments (match existing repository JSDoc
style and wording). Locate the JSDoc comments immediately above the `releases`
and `changelogs` function definitions and replace `@return` with `@returns` and
add missing `@param` lines where applicable.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: f82a5e7e-4e9e-4480-bee4-f03a4ed0cfc2

📥 Commits

Reviewing files that changed from the base of the PR and between cf58689 and f8bf9ca.

📒 Files selected for processing (1)
  • modules/home/services/home.service.js

Tests now expect 200 with empty data when GitHub API fails, matching
the service's catch-and-return-empty-array behavior.
@PierreBrisorgueil
PierreBrisorgueil merged commit e8e20aa into master Mar 24, 2026
3 checks passed
@PierreBrisorgueil
PierreBrisorgueil deleted the fix/home-github-graceful branch March 24, 2026 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(home): handle GitHub API failures gracefully in releases/changelogs

2 participants