Skip to content

fix: raise HTTPError on HTTP 5xx instead of returning an empty list - #92

Merged
lwoodblake merged 1 commit into
masterfrom
fix-raise-on-server-errors
Oct 20, 2026
Merged

lwoodblake merged 1 commit into
masterfrom
fix-raise-on-server-errors

Conversation

@willnewton

Copy link
Copy Markdown
Contributor

Fixes #71

Problem

get_resource swallowed every non-200 response and returned [], so transient server errors (e.g. 504s during bulk loads) were indistinguishable from a legitimately empty result and data was silently dropped.

Change

  • 5xx responses now call resp.raise_for_status(), raising requests.HTTPError so callers can catch and retry.
  • 4xx behaviour is unchanged (print and return []), since e.g. a 404 can mean "no data yet / no 360 frames".
  • The endpoint-versions lookup catches HTTPError and falls back to the hardcoded VERSIONS.
  • Added tests/statsbombpy_test/test_api_client.py.

Not included: built-in retry logic; callers can add their own around the raised error.

Notes

Behaviour change: code that relied on a 5xx quietly returning an empty result will now get an exception. The 16 failures in test_sb.py also occur on clean master (they need network/credentials).

🤖 Generated with Claude Code

Server errors such as 504s were swallowed and indistinguishable from an
empty result. 4xx behaviour is unchanged.

Refs #71

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@orca-security-us orca-security-us Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Orca Security Scan Summary

Status Check Issues by priority
Passed Passed Infrastructure as Code high 0   medium 0   low 0   info 0 View in Orca
Passed Passed Secrets high 0   medium 0   low 0   info 0 View in Orca

@lwoodblake lwoodblake left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This fixes issue #71 and tests pass. Approve.

@lwoodblake
lwoodblake merged commit 5e3c16e into master Oct 20, 2026
5 of 8 checks passed
@lwoodblake
lwoodblake deleted the fix-raise-on-server-errors branch October 20, 2026 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Client HTTP Error Handling

2 participants