Skip to content

fix: include request method and path in ApifyApiError messages - #1185

Merged
vdusek merged 2 commits into
apify:masterfrom
kocaemre:fix/api-error-request-path-1177
Nov 2, 2026
Merged

vdusek merged 2 commits into
apify:masterfrom
kocaemre:fix/api-error-request-path-1177

Conversation

@kocaemre

@kocaemre kocaemre commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Include the HTTP method and request path in ApifyApiError, without exposing URL query parameters (including token). Custom HTTP clients constructing the error without a URL keep the existing exception text.
  • Name the HTTP status in fallback messages, including for an empty response body.
  • Cover sync and async requests through both built-in transports.

Fixes #1177

Verification

  • RED (test before implementation): uv run --extra httpx2 --extra brotli pytest tests/unit/test_client_errors.py -k 'identifies_request_without_exposing_query_token or empty_body_names_http_status' -q -o addopts='' --tb=short → 6 expected failures (missing path, empty-body fallback missing HTTP 502).
  • GREEN: uv run --extra httpx2 --extra brotli pytest tests/unit/test_client_errors.py -q -o addopts='' --tb=short → 94 passed.
  • uv run --extra httpx2 --extra brotli pytest tests/unit -q -n 4 -o addopts='' --tb=short → 2418 passed, 1 skipped.
  • uv run --extra httpx2 --extra brotli ruff check src/apify_client/errors.py src/apify_client/http_clients/_base.py tests/unit/test_client_errors.py → passed.
  • uv run --extra httpx2 --extra brotli ruff format --check src/apify_client/errors.py src/apify_client/http_clients/_base.py tests/unit/test_client_errors.py → passed.
  • uv run --extra httpx2 --extra brotli poe check-docstrings and uv run --extra httpx2 --extra brotli ty check src/apify_client/errors.py src/apify_client/http_clients/_base.py → passed.
  • git diff --check → passed. No live Apify API calls.

AI assistance: implementation and tests were developed with an AI agent and verified locally.

@github-actions github-actions Bot added the t-tooling Issues with this label are in the ownership of the tooling team. label Oct 30, 2026
@vdusek vdusek changed the title fix: identify failed API requests without exposing query tokens fix: include request method and path in ApifyApiError messages Nov 2, 2026
@vdusek
vdusek self-requested a review November 2, 2026 10:56
@vdusek
vdusek merged commit 25a64b6 into apify:master Nov 2, 2026
37 checks passed
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.

Add the request URL to ApifyApiError and improve the message for an empty error body

2 participants