Skip to content

feat: overcharge by one event when the PPE budget is exhausted - #1191

Open
vdusek wants to merge 7 commits into
masterfrom
feat/ppe-overcharge-by-one
Open

vdusek wants to merge 7 commits into
masterfrom
feat/ppe-overcharge-by-one

Conversation

@vdusek

@vdusek vdusek commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

When a charge goes over the remaining max_total_charge_usd budget, the SDK charges one event more than the budget covers, so the platform detects the exhausted budget and stops the run. push_data lets one item through when the budget can't cover a single one, and a run that is already strictly over budget gets nothing more. This ports the JS SDK behavior from apify/apify-sdk-js#574. As in JS, the push data limit applies only to pay-per-event runs.

It changes what users see: a run sitting exactly at its budget gets one more event on the next charge, max_total_charge_usd=0 lets one event through, and callers that ignore ChargeResult can get one extra charged event and dataset item. The charge() docstrings and the exceptions docs page describe the rule.

The PPE E2E tests are updated for the new counts. test_actor_charge_limit expects 3 charges, as the JS E2E test does. The Scrapy PPE spider test uses a $0.075 budget, expects 2 charges and 2 items, and accepts SUCCEEDED or ABORTED, since the platform's abort can race the Actor's own exit.

Closes: #1187

✍️ Drafted by Claude Code

@vdusek vdusek added the t-tooling Issues with this label are in the ownership of the tooling team. label Oct 16, 2026
@vdusek vdusek self-assigned this Oct 16, 2026
@codecov

codecov Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.10%. Comparing base (290af90) to head (9fbb5db).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1191      +/-   ##
==========================================
+ Coverage   93.00%   93.10%   +0.10%     
==========================================
  Files          54       54              
  Lines        3672     3683      +11     
==========================================
+ Hits         3415     3429      +14     
+ Misses        257      254       -3     
Flag Coverage Δ
e2e 31.65% <6.25%> (-0.07%) ⬇️
integration 51.56% <6.25%> (-0.13%) ⬇️
unit 89.84% <100.00%> (+0.11%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@vdusek
vdusek marked this pull request as ready for review October 16, 2026 11:32
@vdusek
vdusek requested a review from szaganek as a code owner October 16, 2026 11:32
@vdusek
vdusek requested review from Mantisus and Pijukatel and removed request for szaganek October 16, 2026 11:32
@apify-service-account apify-service-account added the tested Temporary label used only programatically for some analytics. label Oct 16, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t-tooling Issues with this label are in the ownership of the tooling team. tested Temporary label used only programatically for some analytics.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Overcharge by one event when the budget is exhausted

2 participants