Skip to content

fix(cli): report a job's real exit code and stop claiming stops [PC-4873] - #1835

Draft
robert-ursu wants to merge 1 commit into
mainfrom
feat/async-job-dispatch-and-result-push
Draft

robert-ursu wants to merge 1 commit into
mainfrom
feat/async-job-dispatch-and-result-push

Conversation

@robert-ursu

@robert-ursu robert-ursu commented Jul 30, 2026 •

Copy link
Copy Markdown
Collaborator

Draft. First PR of the job stop / exit code stack (PC-4873). Re-cut on main @ 7bd1425 (2.14.25). The old async-dispatch and result-push content is gone: #1883 and #1906 (logs and result over IPythonJobApi) superseded it. The parts that were still missing on main are what this PR keeps.

Stack: this PR → #1842 (real cooperative stop over IPC and HTTP) → hdens handler PRs that act on the stop verdict.

Why

A failed job running inside uipath server was reported as a success, on both transports:

  1. ConsoleLogger.error ends in click.get_current_context().exit(1). Under standalone_mode=False click returns that code instead of raising (click/core.py, except Exit). _run_command_isolated took the return value as the job's result and hard-coded ExitCode: 0. Every console.error path (runtime errors, unexpected exceptions, bad --simulation) came back as exit code 0.
  2. The HTTP /jobs/{key}/start reply had no exitCode. The .NET PythonRuntimeClient reads exitCode into an int and treats a missing one as 0, so every HTTP 200 counted as a success, even when the body said success: false.

The handler usually overrides the exit code with the status in output.json or the IPC result. The exit code decides the outcome when neither exists: failures before or outside UiPathRuntimeContext, and crashes.

What

  • _server_core: an int returned by cmd.main is the exit code. run, debug and eval never return an int of their own.
  • HTTP start reply: exitCode is added to every response. An unchanged handler becomes correct against this runtime with no .NET change.
  • IPC StopJob returns False and logs a warning. It used to log "(no-op)" and return True, which claimed a stop that never happened. feat(cli): really stop a job that uipath server is running [PC-4873] #1842 replaces this with a real stop.
  • _job_api: a result status the sink does not know is reported as Faulted, not Successful. "stopped" maps to the wire's Stopped (4), which the handler already accepts.
  • uipath run / uipath eval: entrypoint or eval-set discovery failure exits 1 instead of 0.

Compatibility

  • HTTP: additive field.
  • IPC: StopJob's wire shape is unchanged. Only the value changes, and today's handler ignores it.
  • CLI: discovery failure now exits non-zero, for interactive users too.
  • Version 2.14.25 → 2.14.26.

Testing

  • uv run pytest tests/cli: 1502 passed, 1 skipped, 1 xfailed.
  • ruff check, ruff format --check and mypy are clean.
  • New tests:
    • a real click command that calls ConsoleLogger.error reports exit code 1 through the job core;
    • an HTTP job whose entrypoint raises replies success: false, exitCode: 1;
    • unknown status maps to Faulted, and "stopped" to Stopped.
  • Updated tests: StopJob now returns False, and the discovery tests expect exit code 1.

Jira

PC-4873

🤖 Generated with Claude Code

https://claude.ai/code/session_01CFMKm7zHGcptS49z4cnnad

@github-actions github-actions Bot added test:uipath-langchain Triggers tests in the uipath-langchain-python repository test:uipath-integrations labels Jul 30, 2026
Comment thread packages/uipath/src/uipath/_cli/_server_jobs.py Fixed
@robert-ursu
robert-ursu force-pushed the feat/async-job-dispatch-and-result-push branch from 3de1eda to 114a204 Compare August 4, 2026 10:54
@robert-ursu
robert-ursu force-pushed the feat/async-job-dispatch-and-result-push branch from 114a204 to 71c81e9 Compare August 4, 2026 11:13
@robert-ursu robert-ursu changed the title feat(cli): dispatch jobs asynchronously and push results/logs to the caller feat(cli): dispatch jobs asynchronously and push results/logs to the caller [PC-4873] Aug 4, 2026
@robert-ursu
robert-ursu force-pushed the feat/async-job-dispatch-and-result-push branch from 6c8af15 to e509941 Compare August 19, 2026 19:13
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
82.6% Coverage on New Code (required ≥ 90%)
B Security Rating on New Code (required ≥ A)
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

…873]

Under standalone_mode=False click returns ctx.exit(N)'s code instead of
raising, so every ConsoleLogger.error path came back as a result and the job
core reported ExitCode 0. Map a returned int to the exit code.

The HTTP start reply now carries exitCode, the field the .NET HTTP client
already reads (it defaulted a missing one to 0, so every 200 was a success).

StopJob returns False: this server cannot stop a running job, and the
handler must not be told it did.

A result status the IPC sink does not know is reported as Faulted instead of
Successful, and "stopped" maps to the wire's Stopped.

Entrypoint discovery failures in `uipath run` and `uipath eval` exit 1.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CFMKm7zHGcptS49z4cnnad
@robert-ursu
robert-ursu force-pushed the feat/async-job-dispatch-and-result-push branch from e509941 to db4653c Compare September 24, 2026 15:12
@robert-ursu robert-ursu changed the title feat(cli): dispatch jobs asynchronously and push results/logs to the caller [PC-4873] fix(cli): report a job's real exit code and stop claiming stops [PC-4873] Sep 24, 2026
@sonarqubecloud

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

🚨 Heads up: uipath-langchain cross-tests are FAILING 🚨

Your changes may break the uipath-langchain-python integration.

⚠️ These checks are NOT enforced by branch protection rules. Please review the failures before merging.

🔍 Inspect the failed run →

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

test:uipath-integrations test:uipath-langchain Triggers tests in the uipath-langchain-python repository test:uipath-runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants