Skip to content

fix: raise HTTPError on failed API responses instead of returning None#44

Merged
EarningsCall merged 1 commit intomasterfrom
fix/raise-on-symbols-fetch-failure
Mar 11, 2026
Merged

fix: raise HTTPError on failed API responses instead of returning None#44
EarningsCall merged 1 commit intomasterfrom
fix/raise-on-symbols-fetch-failure

Conversation

@EarningsCall
Copy link
Owner

@EarningsCall EarningsCall commented Mar 11, 2026

Summary

  • get_symbols_v2(), get_sp500_companies_txt_file(), get_events(), and get_exchanges_json() now raise HTTPError on failed API responses instead of silently returning the raw response. Previously, non-200 responses were passed through to callers, which would then crash with AttributeError (e.g., calling .split() on a non-text response) or return corrupt data.
  • _get_events() in Company now handles HTTPError (returns [] on 404), consistent with get_transcript(), download_audio_file(), and download_slide_deck().
  • Added return type hints to all public functions in api.py
  • Added error-path unit tests (404/500) with status code assertions for all fixed functions
  • Fixed missing @responses.activate decorator on test_download_audio_file_missing_params_raises_value_error
  • Bumps version to 2.0.1

Test plan

  • All 89 tests pass (pytest)
  • New tests assert HTTPError is raised with correct status code in message ("500 Server Error", "404 Client Error")
  • company.events() returns [] on 404, raises on 500
  • Existing test_get_sp_500_companies_failed_request updated to expect HTTPError instead of empty list
  • Coverage increased +0.8% to 97.48%

🤖 Generated with Claude Code

@EarningsCall EarningsCall force-pushed the fix/raise-on-symbols-fetch-failure branch 2 times, most recently from bdfddd8 to ddf3d0d Compare March 11, 2026 12:15
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

@EarningsCall EarningsCall force-pushed the fix/raise-on-symbols-fetch-failure branch from ddf3d0d to bd04a4e Compare March 11, 2026 12:19
@EarningsCall
Copy link
Owner Author

Bugbot finding addressed: _get_events() now catches HTTPError and returns [] on 404, consistent with get_transcript, download_audio_file, and download_slide_deck. Added tests for both 404 and 500 cases.

@EarningsCall EarningsCall force-pushed the fix/raise-on-symbols-fetch-failure branch from bd04a4e to a97a237 Compare March 11, 2026 12:36
Functions like get_symbols_v2(), get_sp500_companies_txt_file(),
get_events(), and get_exchanges_json() silently returned the raw
response on HTTP errors, causing downstream callers to crash with
AttributeError when trying to use the result. Now all four use
response.raise_for_status() consistently, matching the pattern
already used by get_transcript() and download_audio_file().

Adds HTTPError handling to _get_events() in company.py so 404
returns [] instead of crashing (consistent with other methods).

Also adds return type hints to all public functions in api.py,
error-path unit tests (404/500) for all fixed functions, and fixes
a missing @responses.activate decorator on an existing test.

Bumps version to 2.0.1.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@EarningsCall EarningsCall force-pushed the fix/raise-on-symbols-fetch-failure branch from a97a237 to c8b41e9 Compare March 11, 2026 13:28
@EarningsCall EarningsCall merged commit 4b6ed91 into master Mar 11, 2026
10 checks passed
@EarningsCall EarningsCall deleted the fix/raise-on-symbols-fetch-failure branch March 11, 2026 13:36
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