Skip to content

feat(pipeline-run): surface API HTTP failures as clean errors#38

Open
arseniy-pplx wants to merge 1 commit into
TangleML:masterfrom
arseniy-pplx:transfer/clean-sdk-http-errors
Open

feat(pipeline-run): surface API HTTP failures as clean errors#38
arseniy-pplx wants to merge 1 commit into
TangleML:masterfrom
arseniy-pplx:transfer/clean-sdk-http-errors

Conversation

@arseniy-pplx

Copy link
Copy Markdown

Summary

  • add a shared HTTP-error formatter and surface_http_errors context manager for SDK commands
  • report API status, reason, method, URL and a bounded, whitespace-collapsed response body as one-line command errors
  • wrap pipeline-run manager API calls (status, details, cancel, graph-state, logs, list/search, export, submit) and annotation commands while preserving client-level recovery, post-submit run recovery, and fallback behavior
  • report per-run graph-state failures with the same formatted message in each result's error field

Context

Pipeline-run SDK commands currently leak raw requests tracebacks when the API returns a non-2xx response. The command layer already converts PipelineRunError to a clean non-zero exit; this change makes HTTP failures on sdk pipeline-runs commands cross that boundary instead. Client-internal recovery (the 404 run-id -> execution-id fallback, submission-id run recovery after a failed submit) keeps handling the statuses it can; only unrecovered errors are formatted.

Behavior note for downstream hook subclasses: on_poll_error and on_submit_error now receive PipelineRunError (with the original requests.HTTPError chained as __cause__) instead of the raw HTTPError when an API call fails with an HTTP status error. Non-HTTP submit errors reach on_submit_error unchanged.

Testing

  • uv run pytest tests/test_sdk_http_errors.py tests/test_pipeline_runs_cli.py
  • uvx ruff check on the touched source files
  • uv lock --check
  • git diff --check

Pipeline-run SDK commands leaked raw requests tracebacks whenever the API answered non-2xx. Manager and annotation methods that call the client now run under a shared error-surfacing context manager that re-raises requests.HTTPError as PipelineRunError with the status, reason, method, URL and a single-line, trimmed response body, so sdk pipeline-runs commands (including submit and annotations) exit non-zero with a one-line message. Client-internal recovery such as the 404 run-id to execution-id fallback and post-submit run recovery keeps handling the statuses it can; per-run graph-state failures reuse the formatted message in each result's error field. on_poll_error and on_submit_error hooks now receive PipelineRunError with the original HTTPError chained as __cause__.
@arseniy-pplx
arseniy-pplx marked this pull request as ready for review July 20, 2026 18:11
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.

1 participant