Open
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #751 +/- ##
=======================================
Coverage 95.22% 95.22%
=======================================
Files 45 45
Lines 5154 5154
=======================================
Hits 4908 4908
Misses 246 246
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
The billing endpoint body was built with `count or 1`, which silently rewrote a legitimate `count=0` to `count=1` — on a pay-per-event endpoint, the difference is financially material. Use an explicit `None` check instead. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
463e742 to
0faf061
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
RunClient.charge(and its async counterpart) built the request body with'count': count or 1. The short-circuitortreats0as falsy, so a caller passingcount=0— e.g.count=len(batch)where the batch ended up empty, or a defensive no-op — was silently billed ascount=1. On a pay-per-event billing endpoint the difference is financially material.Replaced
count or 1with an explicitcount if count is not None else 1at both call sites, and clarified the docstring so thecount=0behaviour is documented rather than implicit.Added a parametrized unit test (
tests/unit/test_run_charge.py) coveringNone,0,1, and5for both sync and async clients; the0case fails on master and passes with this fix.