Repository navigation
Closed
Labels
enhancementNew feature or request.New feature or request.t-toolingIssues with this label are in the ownership of the tooling team.Issues with this label are in the ownership of the tooling team.
Description
When a charge exceeds the remaining maxTotalChargeUsd budget, ChargingManager.charge() caps the count with min() (source), and the push-data limits do the same for dataset items (compute_push_data_limit, PPE dataset mixin). The platform never sees a charge over the budget, so an Actor that ignores the returned ChargeResult keeps running and doing unpaid work until it times out.
The JS SDK charges one event over the budget in that case, so the platform detects the overspend and terminates the run, unless the run is already strictly over budget (charge(), calculatePushDataLimit()). This came from apify/apify-sdk-js#574, which fixed apify/apify-sdk-js#572.
Acceptance criteria
charge()chargesmax_chargeable + 1events whencountexceeds the remaining budget and the total charged amount is not already over the limit.push_data()and the default-dataset PPE path let one item through when the budget cannot cover a single item, under the same condition; a partially covered push is still capped to what the budget allows.- Unit tests updated, including the local PPE mode.
Implementation notes
ChargingManager.charge()(_charging.py#L344-L353): whencount > max_chargeableandcalculate_total_charged_amount() <= max_total_charge_usd, chargemax_chargeable + 1; when the run is already strictly over budget, charge 0. Port the condition from JScharge()as is.compute_push_data_limit()(#L467-L484) andDatasetClientPpeMixin._compute_limit_for_push()(_ppe_dataset_mixin.py#L12-L18): follow JScalculatePushDataLimit(), letting one item through only when the budget can't cover a single one.ChargeResult.event_charge_limit_reachedmust still reportTrueafter the extra event.- Update the capped-count assertions in
tests/unit/actor/test_actor_charge.pyandtests/unit/actor/test_charging_manager.py, and add cases for the "already over budget" branch and the local (off-platform) mode.
✍️ Drafted by Claude Code
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request.New feature or request.t-toolingIssues with this label are in the ownership of the tooling team.Issues with this label are in the ownership of the tooling team.
Activity
feat: overcharge by one event when the PPE budget is exhausted (#1191)