fix(home): handle GitHub API failures gracefully in releases/changelogs#3292
Conversation
…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.
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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 configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
WalkthroughAdded try/catch error handling to releases() and changelogs() to return empty arrays on GitHub API failures; changelogs() now uses the filtered repo title ( Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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()andchangelogs()withtry/catchand return[]on failure. - Simplify async returns by returning arrays directly (instead of
Promise.resolve(...)). - Fix changelog title mapping to use the filtered
reposlist when building results.
There was a problem hiding this comment.
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 | 🟠 MajorUpdate JSDoc tags to
@returnson modified async functions.
releasesandchangelogswere modified, but their headers still use@returninstead 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@paramfor 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
📒 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.
Summary
releases()andchangelogs()GitHub API calls in try/catchauth.authorization.integration.tests.jsfailures when GitHub API is rate-limitedCloses #3291
Summary by CodeRabbit
Bug Fixes
Tests