Skip to content

fix: send the graceful abort flag in the request body - #1197

Closed
Pijukatel wants to merge 2 commits into
masterfrom
claude/wonderful-archimedes-088txx
Closed

Pijukatel wants to merge 2 commits into
masterfrom
claude/wonderful-archimedes-088txx

Conversation

@Pijukatel

Copy link
Copy Markdown
Contributor

RunClient.abort() now sends the gracefully flag as a JSON body instead of a query parameter, in both the sync and async client.
The flag is left out of the body when the caller does not set it, so the default request stays unchanged.
Unit tests cover the default, graceful, and forced variants.


Generated by Claude Code

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ocuALBprYy13aVai5MaVb
@github-actions github-actions Bot added the t-tooling Issues with this label are in the ownership of the tooling team. label Nov 4, 2026
@codecov

codecov Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.71%. Comparing base (1790b0e) to head (abc3fc1).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1197      +/-   ##
==========================================
+ Coverage   95.68%   95.71%   +0.03%     
==========================================
  Files          62       62              
  Lines        6651     6656       +5     
==========================================
+ Hits         6364     6371       +7     
+ Misses        287      285       -2     
Flag Coverage Δ
integration 91.25% <80.00%> (+0.18%) ⬆️
unit 90.74% <100.00%> (+0.09%) ⬆️

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.

@apify-factory apify-factory left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One thing to fix before merge.

Compared with:

  • apify/apify-core src/api/src/routes/actor_runs/run_abort.ts:28: The POST abort handler reads gracefully only from req.query via parseBooleanParameter and never reads the request body.
  • apify/apify-client-js src/resource_clients/run.ts:156: The JS RunClient.abort() sends gracefully as a query param via buildParams, with no body, which this change no longer matches.
  • apify/apify-sdk-python src/apify/_actor.py:1169: Actor.abort() and _child_runs.py:267 call run_client.abort(gracefully=...), and with this change those calls would silently lose the graceful behaviour.

🏭 Factory review — ℹ️ not auto-approved

This change was reviewed but cannot be auto-approved: a gate failed, so the review cannot end in an approval.

check result
Static gates ❌ 15/16 — pr-open-and-ready
Review findings ❌ not clean
Reviewer escalation ❌ Changes the wire format of a public API call (the abort request), and the API does not accept the new format.
Juror 1 — claude-sonnet-5-5, adversarial ⏭️ skipped — a gate failed
Why it was not auto-approved

Failed gates:

  • pr-open-and-ready: PR is a draft

The comments above are the review itself; this section only explains the approval decision. Push a change and request @apify-factory again to re-run it, or ask a human to review.

Reviewed 210ad0bd1 · workflow run

method='POST',
params=self._build_params(gracefully=gracefully),
headers={'content-type': 'application/json'},
data=json.dumps(_build_abort_body(gracefully=gracefully)),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Important: the abort handler reads gracefully only from the query string, so moving it into the JSON body means the API silently ignores it and abort(gracefully=True) always aborts immediately. (apify-core src/api/src/routes/actor_runs/run_abort.ts:28)

method='POST',
params=self._build_params(gracefully=gracefully),
headers={'content-type': 'application/json'},
data=json.dumps(_build_abort_body(gracefully=gracefully)),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Important: the async client has the same problem. The API never reads gracefully from the body, so Actor.abort(gracefully=True) in the SDK and the graceful abort of child runs both stop running Actors right away and skip the aborting/persistState events. (apify-sdk-python src/apify/_child_runs.py:267)

@apify-factory apify-factory left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One thing to fix before merge.

🏭 Factory review — ℹ️ not auto-approved

This change was reviewed but cannot be auto-approved: a gate failed, so the review cannot end in an approval.

check result
Static gates ❌ 15/16 — pr-open-and-ready
Review findings ❌ not clean
Reviewer escalation ❌ Changes the wire format of a public API call used by the Python SDK (Actor.abort and child-run cleanup), and the API does not read the new body field.
Juror 1 — claude-sonnet-5-5, adversarial ⏭️ skipped — a gate failed
Why it was not auto-approved

Failed gates:

  • pr-open-and-ready: PR is a draft

The comments above are the review itself; this section only explains the approval decision. Push a change and request @apify-factory again to re-run it, or ask a human to review.

Reviewed 210ad0bd1 · workflow run

method='POST',
params=self._build_params(gracefully=gracefully),
headers={'content-type': 'application/json'},
data=json.dumps(_build_abort_body(gracefully=gracefully)),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Important: the abort handler reads gracefully only from the query string and ignores the body, so abort(gracefully=True) now aborts the run immediately instead of gracefully (same in the async client at line 691). (apify-core src/api/src/routes/actor_runs/run_abort.ts:28)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ocuALBprYy13aVai5MaVb

@apify-factory apify-factory left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

One thing to fix before merge.

🏭 Factory review — ℹ️ not auto-approved

This change was reviewed but cannot be auto-approved: a gate failed, so the review cannot end in an approval.

check result
Static gates ❌ 15/16 — pr-open-and-ready
Review findings ❌ not clean
Reviewer escalation ❌ Changes the wire format of a public API call, and the API does not accept the new format.
Juror 1 — claude-sonnet-5-5, adversarial ⏭️ skipped — a gate failed
Why it was not auto-approved

Failed gates:

  • pr-open-and-ready: PR is a draft

The comments above are the review itself; this section only explains the approval decision. Push a change and request @apify-factory again to re-run it, or ask a human to review.

Reviewed abc3fc107 · workflow run

method='POST',
params=self._build_params(gracefully=gracefully),
headers={'content-type': 'application/json'},
data=json.dumps(_build_abort_body(gracefully=gracefully)),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Important: the abort endpoint only reads gracefully from the query string, so a flag sent in the body is ignored. Every abort(gracefully=True) call, including the SDK's Actor.abort and child-run cleanup, now does a hard abort instead of a graceful one. (apify-core src/api/src/routes/actor_runs/run_abort.ts:28)

method='POST',
params=self._build_params(gracefully=gracefully),
headers={'content-type': 'application/json'},
data=json.dumps(_build_abort_body(gracefully=gracefully)),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Important: the async client has the same regression. The API never reads gracefully from the body, so await abort(gracefully=True) silently turns into a forced abort. (apify-core src/api/src/routes/actor_runs/run_abort.ts:28)

@Pijukatel

Copy link
Copy Markdown
Contributor Author

Testing the AI review. Seems ok.

@Pijukatel Pijukatel closed this Nov 4, 2026
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants