-
Notifications
You must be signed in to change notification settings - Fork 515
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add retries for fetching SBOM data #9972
Conversation
WalkthroughThe changes modify the SBOM data fetching script to introduce a retry mechanism with exponential backoff. A new Changes
Sequence DiagramsequenceDiagram
participant Caller
participant fetchSbomData
participant GitHub
Caller->>fetchSbomData: Call with repo, retries
loop Retry Mechanism
fetchSbomData->>GitHub: Fetch SBOM Data
alt Fetch Successful
GitHub-->>fetchSbomData: Return Data
fetchSbomData-->>Caller: Return Data
else Fetch Failed
fetchSbomData->>fetchSbomData: Wait (Exponential Delay)
fetchSbomData->>GitHub: Retry Fetch
end
end
Poem
Finishing Touches
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
✅ Deploy Preview for care-ohc ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Deploying care-fe with Cloudflare Pages
|
CARE Run #4318
Run Properties:
|
Project |
CARE
|
Branch Review |
rithviknishad/feat/sbom-retries
|
Run status |
Passed #4318
|
Run duration | 01m 47s |
Commit |
464d9ce58e: Add retries for fetching SBOM data
|
Committer | Rithvik Nishad |
View all properties for this run ↗︎ |
Test results | |
---|---|
Failures |
0
|
Flaky |
0
|
Pending |
0
|
Skipped |
0
|
Passing |
4
|
View all changes introduced in this branch ↗︎ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (2)
scripts/generate-sbom-data.ts (2)
18-23
: Add error handling for rate limits.The GitHub API has rate limits that should be handled explicitly.
const response = await fetch(url, { headers: { Accept: "application/vnd.github+json", "X-GitHub-Api-Version": "2022-11-28", }, }); + + // Handle rate limits explicitly + if (response.status === 429) { + const retryAfter = response.headers.get('Retry-After'); + if (retryAfter) { + await delay(parseInt(retryAfter, 10) * 1000); + continue; + } + }
25-27
: Add type safety for the response.The response JSON structure should be typed for better type safety.
interface SBOMResponse { // Add expected SBOM response structure sbom: { // ... SBOM fields }; } // Then use it in the return return (await response.json()) as SBOMResponse;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
scripts/generate-sbom-data.ts
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
- GitHub Check: Cloudflare Pages: care-fe
🔇 Additional comments (2)
scripts/generate-sbom-data.ts (2)
9-11
: LGTM! Clean implementation of the delay utility.The Promise-based delay implementation is well-typed and follows best practices.
13-13
: Verify impact of retry mechanism on callers.Let's check for other callers of
fetchSbomData
that might need updates for the new retry parameter.✅ Verification successful
Implementation is safe and backward compatible ✅
The retry parameter is optional with a default value, and all existing calls in the codebase continue to work without modification.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for other callers of fetchSbomData rg "fetchSbomData\(" --type tsLength of output: 209
@rithviknishad Your efforts have helped advance digital healthcare and TeleICU systems. 🚀 Thank you for taking the time out to make CARE better. We hope you continue to innovate and contribute; your impact is immense! 🙌 |
Issue
GitHub's APIs (SBOM), may throw internal 500 error, or network request could randomly fail due to unpredictable reasons which could be one-off exceptions.
Proposed Changes
@ohcnetwork/care-fe-code-reviewers
Merge Checklist
Summary by CodeRabbit
New Features
Bug Fixes