Skip to content

Conversation

@masenf
Copy link
Collaborator

@masenf masenf commented Jan 20, 2026

No description provided.

@codspeed-hq
Copy link

codspeed-hq bot commented Jan 20, 2026

Merging this PR will not alter performance

✅ 8 untouched benchmarks


Comparing masenf/catch-all-exceptions-in-health-check (450d624) with main (2545378)

Open in CodSpeed

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 20, 2026

Greptile Overview

Greptile Summary

Broadened exception handling in health check functions from specific exceptions (OperationalError, RedisError) to catching all exceptions, making the health checks more robust and ensuring they never crash.

  • Changed get_db_status() to catch Exception instead of sqlalchemy.exc.OperationalError
  • Changed get_redis_status() to catch Exception instead of RedisError
  • Removed unused RedisError import from get_redis_status() (still imported within get_redis() where needed)

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The changes improve robustness by broadening exception handling in health check functions, which is appropriate since health checks should never crash. The existing tests remain valid and the removed import was redundant since RedisError is imported locally where it's actually used.
  • No files require special attention

Important Files Changed

Filename Overview
reflex/model.py Broadened exception handling in get_db_status() from OperationalError to all exceptions for more robust health checks
reflex/utils/prerequisites.py Removed unused RedisError import and broadened exception handling in get_redis_status() to catch all exceptions

Sequence Diagram

sequenceDiagram
    participant Client
    participant HealthEndpoint
    participant get_db_status
    participant get_redis_status
    participant Database
    participant Redis

    Client->>HealthEndpoint: GET /health
    HealthEndpoint->>get_db_status: check database
    get_db_status->>Database: SELECT 1
    alt Database responds
        Database-->>get_db_status: Success
        get_db_status-->>HealthEndpoint: {"db": true}
    else Any Exception occurs
        Database-->>get_db_status: Exception
        get_db_status-->>HealthEndpoint: {"db": false}
    end
    
    HealthEndpoint->>get_redis_status: check redis
    get_redis_status->>Redis: ping()
    alt Redis responds
        Redis-->>get_redis_status: Success
        get_redis_status-->>HealthEndpoint: {"redis": true}
    else Any Exception occurs
        Redis-->>get_redis_status: Exception
        get_redis_status-->>HealthEndpoint: {"redis": false}
    end
    
    HealthEndpoint-->>Client: {"status": bool, "db": bool, "redis": bool}
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

No files reviewed, no comments

Edit Code Review Agent Settings | Greptile

Copy link
Contributor

@Kastier1 Kastier1 left a comment

Choose a reason for hiding this comment

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

should we log what the exception is?

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.

3 participants