Add external API health checks: GIPHY, Brawl Stars, ImgBB, bytebin, GitHub#1500
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds five non-critical external API health checks (GIPHY, Brawl Stars, ImgBB, bytebin, GitHub) that read config, perform timed aiohttp GETs, and return HEALTHY/DEGRADED. HealthCheckManager now supports per-check intervals and runs only due checks; startup registers the new checks with configured intervals. ChangesExternal API Health Checks
Sequence DiagramsequenceDiagram
participant AppStartup
participant HealthCheckManager
participant GIPHYHealthCheck
participant BrawlStarsHealthCheck
participant ImgBBHealthCheck
participant BytebinHealthCheck
participant GitHubAPIHealthCheck
participant ExternalAPI as External API
AppStartup->>HealthCheckManager: register(GIPHYHealthCheck, interval)
AppStartup->>HealthCheckManager: register(BrawlStarsHealthCheck, interval)
AppStartup->>HealthCheckManager: register(ImgBBHealthCheck, interval)
AppStartup->>HealthCheckManager: register(BytebinHealthCheck, interval)
AppStartup->>HealthCheckManager: register(GitHubAPIHealthCheck, interval)
AppStartup->>HealthCheckManager: run_startup_checks()
HealthCheckManager->>GIPHYHealthCheck: run()
GIPHYHealthCheck->>ExternalAPI: GET /v1/gifs/trending (api_key)
ExternalAPI-->>GIPHYHealthCheck: HTTP 200 or error
GIPHYHealthCheck-->>HealthCheckManager: HealthStatus (HEALTHY or DEGRADED)
HealthCheckManager->>BrawlStarsHealthCheck: run()
BrawlStarsHealthCheck->>ExternalAPI: GET /v1/brawlers (Bearer token)
ExternalAPI-->>BrawlStarsHealthCheck: HTTP 200, 403, or error
BrawlStarsHealthCheck-->>HealthCheckManager: HealthStatus (HEALTHY or DEGRADED)
HealthCheckManager->>ImgBBHealthCheck: run()
ImgBBHealthCheck->>ExternalAPI: GET /1/upload?key= (api_key)
ExternalAPI-->>ImgBBHealthCheck: HTTP 200, 400, or error
ImgBBHealthCheck-->>HealthCheckManager: HealthStatus (HEALTHY or DEGRADED)
HealthCheckManager->>BytebinHealthCheck: run()
BytebinHealthCheck->>ExternalAPI: GET / (optional Basic auth)
ExternalAPI-->>BytebinHealthCheck: HTTP >=500, 401/403, or error
BytebinHealthCheck-->>HealthCheckManager: HealthStatus (HEALTHY or DEGRADED)
HealthCheckManager->>GitHubAPIHealthCheck: run()
GitHubAPIHealthCheck->>ExternalAPI: GET /user (Bearer token)
ExternalAPI-->>GitHubAPIHealthCheck: HTTP 200, 401, or error
GitHubAPIHealthCheck-->>HealthCheckManager: HealthStatus (HEALTHY or DEGRADED)
Estimated Code Review Effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested Labels
Suggested Reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@external_api_health_checks.py`:
- Around line 43-44: Health-check handlers leak API keys and sensitive request
context by including raw error text (e.g., ClientError/result.message) that
contains query-string URLs like f"https://api.giphy.com...{giphyAPIKey}". Update
the health-check code that calls external APIs (references to giphyAPIKey and
places where exceptions are returned/logged as result.message) to: 1) stop
including full request URLs or exception bodies in responses/logs; 2) redact or
remove query params (mask giphyAPIKey) before logging or include only the
hostname and endpoint path; 3) when possible send keys in Authorization headers
instead of query params to avoid accidental exposure in exception strings; and
4) sanitize the caught ClientError/result.message before returning it to callers
so no raw request context or keys are exposed.
- Around line 214-227: The current check treats 401/403 as healthy; update the
response-status handling in the async block that uses
ClientSession()/session.get(bytebin_url, headers, timeout) so that if basic auth
credentials (bytebin_username and bytebin_password) are configured then
response.status 401 or 403 returns a HealthCheckResult with check_name
self.name, status HealthStatus.DEGRADED and an explanatory message (similar to
the existing 500+ branch); keep the existing behavior for other statuses (e.g.,
>=500) unchanged and use the same HealthCheckResult/HealthStatus.DEGRADED
symbols so the error path is consistent.
In `@main.py`:
- Around line 134-138: The five new checks (GIPHYHealthCheck,
BrawlStarsHealthCheck, ImgBBHealthCheck, BytebinHealthCheck,
GitHubAPIHealthCheck) are being registered into the existing periodic runner
that uses interval=300, so they run every 5 minutes instead of the required
30/60-minute cadences; fix this by registering each check with the correct
cadence—either extend health_manager.register to accept an interval argument and
supply 1800 or 3600 seconds as appropriate for each check, or create separate
periodic runners (e.g., periodic_runner_30m and periodic_runner_60m) and
register the appropriate checks there instead of using the existing interval=300
runner.
🪄 Autofix (Beta)
✅ Autofix completed
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 2babe39c-bd5f-487e-85a2-a44f24767a4b
📒 Files selected for processing (2)
external_api_health_checks.pymain.py
|
Note Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it. Fixes Applied SuccessfullyFixed 3 file(s) based on 3 unresolved review comments. Files modified:
Commit: The changes have been pushed to the Time taken: |
Fixed 3 file(s) based on 3 unresolved review comments. Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
Closes #1414
Summary
Adds five non-critical health checks for external API integrations:
All checks follow the pattern established by
OpenAIHealthCheck. All are non-critical (degraded on failure, never block startup).Changes
external_api_health_checks.py— new file with fiveHealthChecksubclassesmain.py— register all five checks with theHealthCheckManagerSee #1414 for the full specification.
Summary by CodeRabbit