Skip to content

Conversation

@Akol125
Copy link
Contributor

@Akol125 Akol125 commented Jan 29, 2026

Summary

  • Routine Change
    Implemented improved HTTP error handling and retry logic for PDS client integration to support clearer failure diagnostics and resilience against transient downstream failures.

Also made the mns error handling function reusable and moved to shared, so it can be re-used for PDS

Reviews Required

  • Dev
  • Test
  • Tech Author
  • Product Owner

Review Checklist

ℹ️ This section is to be filled in by the reviewer.

  • I have reviewed the changes in this PR and they fill all of the acceptance criteria of the ticket.
  • If there were infrastructure, operational, or build changes, I have made sure there is sufficient evidence that the changes will work.
  • If there were changes that are outside of the regular release processes e.g. account infrastructure to setup, manual setup for external API integrations, secrets to set, then I have checked that the developer has flagged this to the Tech Lead as release steps.
  • I have checked that no Personal Identifiable Data (PID) is logged as part of the changes.

@github-actions
Copy link
Contributor

This branch is working on a ticket in the NHS England VED JIRA Project. Here's a handy link to the ticket:

VED-240

@Akol125 Akol125 changed the title VED-240-handle-rate-limit VED-240 Handle-rate-limit Jan 29, 2026
@Akol125 Akol125 temporarily deployed to internal-dev-sandbox January 29, 2026 22:25 — with GitHub Actions Inactive
@Akol125 Akol125 had a problem deploying to internal-dev-sandbox January 29, 2026 22:29 — with GitHub Actions Failure
@sonarqubecloud
Copy link

@Akol125 Akol125 temporarily deployed to internal-dev-sandbox January 30, 2026 15:47 — with GitHub Actions Inactive
@Akol125 Akol125 temporarily deployed to internal-dev-sandbox January 30, 2026 15:51 — with GitHub Actions Inactive
@Akol125 Akol125 temporarily deployed to internal-dev-sandbox January 30, 2026 15:51 — with GitHub Actions Inactive
@Akol125 Akol125 changed the title VED-240 Handle-rate-limit VED-240 Handle-PDS-Rate-Limit Jan 30, 2026


def request_with_retry_backoff(
url: str, headers: dict, *, timeout: int = 5, max_retries: int = 2, backoff_seconds: float = 0.5
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we put these default values somewhere as constants?

# Ensure retryable codes include 429/5xx only (example)
with patch.object(Constants, "RETRYABLE_STATUS_CODES", {429, 500, 502, 503, 504}):
# Act
resp = request_with_retry_backoff("http://example.com", {}, max_retries=2, backoff_seconds=0.5)
Copy link
Contributor

Choose a reason for hiding this comment

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

We're using the default values for max_retries and backoff_seconds each time we call request_with_retry_backoff() here - should we just leave them out?

}
response = requests.get(f"{self.base_url}/{patient_id}", headers=request_headers, timeout=5)
response = request_with_retry_backoff(
f"{self.base_url}/{patient_id}", headers=request_headers, timeout=5, max_retries=2, backoff_seconds=0.5
Copy link
Contributor

Choose a reason for hiding this comment

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

We're using the default values for timeout, max_retries and backoff_seconds here - should we just leave them out?

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