feat(call): emit explicit final run status and JSON output (#1139)#1198
Open
l2ysho wants to merge 3 commits into
Open
feat(call): emit explicit final run status and JSON output (#1139)#1198l2ysho wants to merge 3 commits into
l2ysho wants to merge 3 commits into
Conversation
`apify call` and `apify task run` started a cloud run and streamed logs, but gave no explicit final result — a run could start successfully yet finish FAILED, TIMED_OUT, or ABORTED with no clear signal. Agents and CI could not tell "run started" from "run succeeded". Add a shared `run-result` module that owns the final-status contract: - `getRunExitCode` maps terminal status to a process exit code (SUCCEEDED→0, ABORTED→3, TIMED-OUT→2, FAILED→the Actor's own exit code or 1). - `buildRunResultJson` produces the structured `--json` payload (ok, operation, actor, run.status, run.exitCode, storage, error.logTail, exitCode). - `printRunResultSummary` prints a human-readable final summary, including a Reason block with the last log lines on failure. - `finalizeRun` is the single entry point both commands funnel through. `apify task run` now waits for the run to finish, gains `--json`, and reports a status-derived exit code. Final-status presentation and exit-code handling move out of `runActorOrTaskOnCloud` into the commands. Failed, timed-out, and aborted runs now exit non-zero. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The final-status contract nests the run status under `run.status` and adds `ok`/`operation`/`exitCode`; update the runs lifecycle e2e to match instead of reading the old top-level `status`. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…-status-and-json-output-for-agents
DaveHanns
reviewed
Jun 23, 2026
| run: { | ||
| id: run.id, | ||
| status: run.status, | ||
| exitCode: run.exitCode ?? null, |
Contributor
There was a problem hiding this comment.
Q: do we need inner exitCode with the top one in place (exitCode: getRunExitCode(run))?
DaveHanns
reviewed
Jun 23, 2026
| datasetUrl: datasetUrl(run.defaultDatasetId), | ||
| }, | ||
| error: ok | ||
| ? null |
Contributor
There was a problem hiding this comment.
Suggestion: let's use the same format as in case of #1199, meaning, the error should be undefined if ok===true.
DaveHanns
reviewed
Jun 23, 2026
| return; | ||
| } | ||
|
|
||
| if (!silent) { |
Contributor
There was a problem hiding this comment.
Suggestion: the silent should silence the json output as well, right?
Now if both silent and json are set, the json output still prints.
DaveHanns
approved these changes
Jun 23, 2026
DaveHanns
left a comment
Contributor
There was a problem hiding this comment.
Pre-approving. The silent vs json should be definitely addressed before merging.
szaganek
approved these changes
Jun 23, 2026
| FLAGS | ||
| -b, --build=<value> Tag or number of the build to run | ||
| (e.g. "latest" or "1.2.34"). | ||
| --json Format the command output as JSON |
Contributor
There was a problem hiding this comment.
Needs a period at the end :D
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.
Closes #1139
apify callandapify task runstarted a cloud run and streamed logs, butgave no explicit final result — a run could start successfully yet finish
FAILED, TIMED_OUT, or ABORTED with no clear signal. Agents and CI could not
tell "run started" from "run succeeded".
Add a shared
run-resultmodule that owns the final-status contract:getRunExitCodemaps terminal status to a process exit code (SUCCEEDED→0,ABORTED→3, TIMED-OUT→2, FAILED→the Actor's own exit code or 1).
buildRunResultJsonproduces the structured--jsonpayload (ok, operation,actor, run.status, run.exitCode, storage, error.logTail, exitCode).
printRunResultSummaryprints a human-readable final summary, including aReason block with the last log lines on failure.
finalizeRunis the single entry point both commands funnel through.apify task runnow waits for the run to finish, gains--json, and reports astatus-derived exit code. Final-status presentation and exit-code handling move
out of
runActorOrTaskOnCloudinto the commands. Failed, timed-out, and abortedruns now exit non-zero.
Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com