Skip to content

Make raise_for_status configurable#159

Open
ofipify wants to merge 1 commit into
ip-tools:mainfrom
ofipify:configure-raise-for-status
Open

Make raise_for_status configurable#159
ofipify wants to merge 1 commit into
ip-tools:mainfrom
ofipify:configure-raise-for-status

Conversation

@ofipify
Copy link
Copy Markdown
Contributor

@ofipify ofipify commented May 14, 2026

As noted in #36 the default behaviour of response.raise_for_status() in _make_request collides with a possible 413 status code when the EPO OPS API considers the given input ambiguous.

This PR will make this configurable by allowing to pass raise_for_status=False when instantiating a client. The default behaviour has been left as-is, so anybody updating the library would not see a difference in behaviour.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 14, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4f02334c-cebf-44e0-b7fb-d351f9003133

📥 Commits

Reviewing files that changed from the base of the PR and between 4b822aa and 46999b8.

📒 Files selected for processing (4)
  • README.md
  • epo_ops/api.py
  • tests/test_api.py
  • tests/test_raise_for_status.py
🚧 Files skipped from review as they are similar to previous changes (3)
  • epo_ops/api.py
  • tests/test_api.py
  • tests/test_raise_for_status.py

Summary by CodeRabbit

  • New Features

    • Client now supports configurable HTTP error handling; by default exceptions are raised on non-success responses, but callers can disable this to receive raw responses.
  • Documentation

    • Updated docs to clarify how error handling behaves and how to disable exception raising.
  • Tests

    • Added tests covering default exception behavior and the disabled-case (including handling of 413 responses).

Walkthrough

Adds a Client constructor flag raise_for_status (default True) to control whether _make_request calls response.raise_for_status(). Updates README and unit tests; adds integration tests that mock an OPS 413 response to verify behavior when the flag is enabled or disabled.

Changes

Conditional Error Handling Feature

Layer / File(s) Summary
Client constructor parameter and conditional error handling
epo_ops/api.py, README.md
Client.__init__ gains raise_for_status=True and stores it; _make_request conditionally calls response.raise_for_status() only when enabled. Adjusts .models import formatting and a minor spacing change; README reflows the Client error-handling text.
Unit tests for raise_for_status configuration
tests/test_api.py
test_instantiate_simple_client now asserts the default Client(...).raise_for_status is True. New test_instantiate_client_without_raise_for_status verifies passing raise_for_status=False sets the flag.
Integration tests with HTTP 413 error responses
tests/test_raise_for_status.py
New fixture mocks OPS token retrieval and a fulltext POST returning HTTP 413 with an XML fault. Tests assert the default Client raises HTTPError for 413, and a Client with raise_for_status=False returns the 413 response and includes fault details in the response text.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • amotl

Poem

🐰 A tiny flag set on a client so spry,
Lets 413s pass by with a sigh,
Tests hop and they check,
Docs tidy and deck,
Tokens renew while the rabbit eats pie. 🥕✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 26.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title clearly and concisely summarizes the main change: making raise_for_status configurable in the client, which is the primary focus of the changeset.
Description check ✅ Passed The pull request description is directly related to the changeset, explaining the motivation from issue #36, the solution implemented, and the backward-compatible approach taken.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.78%. Comparing base (494eb39) to head (46999b8).

Additional details and impacted files
@@             Coverage Diff             @@
##             main     #159       +/-   ##
===========================================
- Coverage   99.54%   87.78%   -11.77%     
===========================================
  Files          18       18               
  Lines         440      442        +2     
===========================================
- Hits          438      388       -50     
- Misses          2       54       +52     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
Member

@amotl amotl left a comment

Choose a reason for hiding this comment

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

Thank you very much. Nit: It looks like earlier commits slipped in, can you rebase on top of current main?

Defaults to the original behaviour of raising for status when making a request to the EPO OPS API
@ofipify ofipify force-pushed the configure-raise-for-status branch from 4b822aa to 46999b8 Compare May 15, 2026 07:13
@ofipify
Copy link
Copy Markdown
Contributor Author

ofipify commented May 15, 2026

Awesome. I've done the rebase so history should be clean now.

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.

2 participants