Skip to content

docs: correct exception handling in request examples - #505

Open
henricop wants to merge 1 commit into
HubSpot:masterfrom
henricop:docs/correct-request-exceptions
Open

henricop wants to merge 1 commit into
HubSpot:masterfrom
henricop:docs/correct-request-exceptions

Conversation

@henricop

@henricop henricop commented Nov 7, 2026

Copy link
Copy Markdown

Fixes #504.

The Files upload example catches the Contacts package's ApiException, so Files API errors escape its handler. Import the exception from hubspot.files and correct the upload error message.

The generic GET/POST api_request examples also catch the Contacts exception even though that request path uses requests. Explain the returned Response, call raise_for_status(), and catch RequestException so the examples handle HTTP and transport failures. SDK runtime behavior and generated clients are unchanged.

Validation (Python 3.11.15):

  • Executed the actual README snippets offline: GET/POST success, HTTP 400, connection failure, and Files success/API error (8 scenarios). The three unhandled exceptions reproduce with the original README; all handlers work after the change.
  • make test: 105 passed. Six existing invalid-escape warnings come from generated HubDB files.
  • git diff --check: passed.

Live HubSpot integration tests were not run because they require account credentials; the examples were checked with mocked transport and the real SDK exception classes.

AI assistance: Codex helped inspect the request paths, edit the examples, and run these checks.

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.

README request examples catch exception classes from the wrong request path

1 participant