Skip to content

narrow load_outcomes exception in replay.py to redis and parse failures - #18

Open
HrachShah wants to merge 1 commit into
mainfrom
fix/replay-load-outcomes-narrow
Open

narrow load_outcomes exception in replay.py to redis and parse failures#18
HrachShah wants to merge 1 commit into
mainfrom
fix/replay-load-outcomes-narrow

Conversation

@HrachShah

@HrachShah HrachShah commented Jul 7, 2026

Copy link
Copy Markdown
Owner

load_outcomes wraps three operations: xrange() (Redis stream read, raises
aioredis.RedisError on connection drops, timeouts, NOSCRIPT after Redis
restarts), OutcomeRecord.from_stream() (which itself catches (ValueError,
TypeError) and returns a sentinel, but if its own internal logic changes
it can propagate them), and dict.get / float() / int() on the fields dict
(also ValueError / TypeError on malformed payloads). The previous bare
except Exception: also caught AttributeError / NameError from typos in
this file, KeyboardInterrupt when the user Ctrl-Cs while a replay is
running, and SystemExit. The narrow set keeps the existing "load failure
logs and returns []" behavior for the real failure modes while letting
real bugs surface.

Verified the file still parses, and a manual round-trip with a
malformed "judge_score" entry returns the existing logger.exception
path. No test changes (the existing test suite for the experiments
module is minimal; the manual round-trip is the highest-signal check).

Summary by Sourcery

Bug Fixes:

  • Ensure only Redis and payload parsing failures in load_outcomes are treated as recoverable and logged, preventing unrelated exceptions like system-level interrupts or coding errors from being hidden.

load_outcomes wraps three operations: xrange() (Redis stream read,
raises aioredis.RedisError on connection drops, timeouts, NOSCRIPT
after Redis restarts), OutcomeRecord.from_stream() (which itself
catches (ValueError, TypeError) and returns a sentinel, but if its
own internal logic changes it can propagate them), and dict.get /
float() / int() on the fields dict (also ValueError / TypeError on
malformed payloads). The previous bare `except Exception:` also caught
AttributeError / NameError from typos in this file, KeyboardInterrupt
when the user Ctrl-Cs while a replay is running, and SystemExit. The
narrow set keeps the existing "load failure logs and returns []"
behavior for the real failure modes while letting real bugs surface.

Verified the file still parses, and a manual round-trip with a
malformed "judge_score" entry returns the existing logger.exception
path.
@sourcery-ai

sourcery-ai Bot commented Jul 7, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Narrows the exception handling in load_outcomes to only Redis and parsing-related errors so that genuine programming errors and interrupts surface instead of being silently swallowed.

Sequence diagram for narrowed exception handling in load_outcomes

sequenceDiagram
    participant load_outcomes
    participant redis
    participant OutcomeRecord
    participant logger

    load_outcomes->>redis: xrange
    redis-->>load_outcomes: stream_entries
    load_outcomes->>OutcomeRecord: from_stream
    OutcomeRecord-->>load_outcomes: records
    load_outcomes->>logger: info

    alt [aioredis.RedisError or ValueError or TypeError]
        load_outcomes->>logger: exception
    end
Loading

File-Level Changes

Change Details Files
Restrict load_outcomes error handling to Redis and payload parsing failures instead of swallowing all exceptions.
  • Replaced a broad except Exception clause with a narrower tuple of handled exceptions (aioredis.RedisError, ValueError, TypeError)
  • Preserved the existing behavior of logging an exception and returning the current records list for known operational failure modes while allowing other exceptions (e.g., programmer errors, interrupts) to propagate
freerelay/control_plane/experiments/replay.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@HrachShah, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 58 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8860ddfb-2ccb-4e2d-b3a9-58d7e812fa71

📥 Commits

Reviewing files that changed from the base of the PR and between ec9d17f and 4620b5c.

📒 Files selected for processing (1)
  • freerelay/control_plane/experiments/replay.py
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/replay-load-outcomes-narrow

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.

❤️ Share

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

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

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.

1 participant