Skip to content

Add external API health checks: GIPHY, Brawl Stars, ImgBB, bytebin, GitHub#1500

Merged
EntchenEric merged 4 commits into
developmentfrom
fix/issue-1414-external-api-health-checks
May 27, 2026
Merged

Add external API health checks: GIPHY, Brawl Stars, ImgBB, bytebin, GitHub#1500
EntchenEric merged 4 commits into
developmentfrom
fix/issue-1414-external-api-health-checks

Conversation

@EntchenEric
Copy link
Copy Markdown
Member

@EntchenEric EntchenEric commented May 27, 2026

Closes #1414

Summary

Adds five non-critical health checks for external API integrations:

  • GIPHY API — validates API key and reaches trending endpoint
  • Brawl Stars API — validates token and lists brawlers
  • ImgBB API — validates API key with upload endpoint (400 = expected without image)
  • bytebin Storage — validates URL and basic auth, checks for server errors
  • GitHub API — validates token and hits /user endpoint

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 five HealthCheck subclasses
  • main.py — register all five checks with the HealthCheckManager

See #1414 for the full specification.

Summary by CodeRabbit

  • New Features
    • Added external service health monitoring for GIPHY, Brawl Stars, ImgBB, bytebin, and GitHub, with checks at startup and on schedule.
    • Per-service scheduling so each external check runs on its own interval.
    • Enhanced detection and reporting: degraded/critical states are tracked and trigger notifications when issues are found.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 27, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 07292f33-e27e-4fc6-9e36-5d9408895836

📥 Commits

Reviewing files that changed from the base of the PR and between e295718 and d14abd8.

📒 Files selected for processing (1)
  • main.py

📝 Walkthrough

Walkthrough

Adds 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.

Changes

External API Health Checks

Layer / File(s) Summary
Health check class implementations
external_api_health_checks.py
Defines five HealthCheck subclasses (GIPHY, Brawl Stars, ImgBB, bytebin, GitHub). Each class exposes name and critical and implements async run() that reads credentials/URL from config, issues an aiohttp GET with a 10s timeout, maps service-specific HTTP statuses to HealthStatus.DEGRADED or HEALTHY, and treats timeouts and aiohttp.ClientError as degraded.
Health manager per-check scheduling
health/manager.py
Adds _check_intervals and _last_results, extends register() to accept an optional interval, and changes the periodic loop to select and run only checks whose per-check (or default) interval is due; updates stored results and notifies on DEGRADED/CRITICAL outcomes from the selected checks.
Startup registration
main.py
Imports the new health checks and registers them with HealthCheckManager during startup, supplying per-check polling intervals (e.g., 30- and 60-minute schedules); note duplicate OpenAIHealthCheck() registration appears in the startup block.

Sequence Diagram

sequenceDiagram
  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)
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested Labels

tanjun-issue-bot

Suggested Reviewers

  • 2000Arion

Poem

🐰 I sniffed the APIs across the net,
GIPHY, Brawl, and ImgBB I met,
Bytebin and GitHub got a gentle poke,
Each check reports healthy or a yoke,
A rabbit hums: "Startup's ready—let's vet!"

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely summarizes the main change: adding five external API health checks with their names listed clearly.
Linked Issues check ✅ Passed All five health checks (GIPHY, Brawl Stars, ImgBB, bytebin, GitHub) are implemented with correct service-specific logic, proper error handling, timeout configuration, and per-check intervals as specified in issue #1414.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing the external API health checks specified in #1414. The HealthCheckManager extension supports per-check intervals, which is necessary for the feature requirements.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/issue-1414-external-api-health-checks

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

@EntchenEric
Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 27, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between b321e4f and a6ff04c.

📒 Files selected for processing (2)
  • external_api_health_checks.py
  • main.py

Comment thread external_api_health_checks.py Outdated
Comment thread external_api_health_checks.py
Comment thread main.py Outdated
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 27, 2026

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Fixes Applied Successfully

Fixed 3 file(s) based on 3 unresolved review comments.

Files modified:

  • external_api_health_checks.py
  • health/manager.py
  • main.py

Commit: e295718fa716ab49e2aab755c4557b32751903e5

The changes have been pushed to the fix/issue-1414-external-api-health-checks branch.

Time taken: 4m 15s

coderabbitai Bot and others added 2 commits May 27, 2026 20:58
Fixed 3 file(s) based on 3 unresolved review comments.

Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
@EntchenEric EntchenEric merged commit 5f7a173 into development May 27, 2026
3 of 7 checks passed
@EntchenEric EntchenEric deleted the fix/issue-1414-external-api-health-checks branch May 27, 2026 21:00
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.

Add External API health checks: GIPHY, Brawl Stars, ImgBB, bytebin, GitHub

1 participant