Skip to content

feat(charging): Support the idempotency_key param in Actor.charge() - #1123

Open
Mantisus wants to merge 8 commits into
apify:masterfrom
Mantisus:charge-idempotency-key
Open

feat(charging): Support the idempotency_key param in Actor.charge()#1123
Mantisus wants to merge 8 commits into
apify:masterfrom
Mantisus:charge-idempotency-key

Conversation

@Mantisus

@Mantisus Mantisus commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

Adds support for the idempotency_key parameter in Actor.charge().

Closes: #1122

@Mantisus Mantisus changed the title feat(charging): Allow passing an idempotency key to charge() feat(charging): Support the idempotency_key param in Actor.charge() Sep 8, 2026
@Mantisus Mantisus self-assigned this Sep 8, 2026
@Mantisus
Mantisus requested a review from vdusek September 8, 2026 21:28
@vdusek
vdusek requested a review from szaganek as a code owner September 11, 2026 11:04
Comment thread src/apify/_charging.py Outdated
Comment on lines +511 to +510
# Only remember a key that stands for a charge the platform actually received. Off the platform there
# is no request at all and the registry is the only thing providing deduplication.
if idempotency_key is not None and (not self._is_at_home or charge_sent):
# Remember the key for every charge that was counted, including events the API never receives, such as
# synthetic and tier-priced ones - those are counted locally and a repeat would count them twice.
if idempotency_key is not None:

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

With this update, the idempotency_key will be saved even for events that do not exist.

@Mantisus

Copy link
Copy Markdown
Collaborator Author

@barjin, Please take a look at the implementation.

In the TS SDK, the idempotency_key doesn't affect the ChargingManager. This will cause desynchronization in cases where the API rejects a request with a duplicate idempotency_key.

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.

Support the idempotency_key param in Actor.charge()

3 participants