Skip to content

Conversation

@Vox-Ben
Copy link
Contributor

@Vox-Ben Vox-Ben commented Feb 10, 2026

Description

This makes the PdsClient generate a fresh UUID with each request to PDS and send it as the X-Request-Id header

Context

PDS requires a fresh X-Request-Id with every request. Previously we were expecting it to be generated by the consumer and passed in, but that is incorrect - it needs to be generated within the PDS module because it is specific to the PDS request and the consumer has no knowledge of it.

Type of changes

  • Refactoring (non-breaking change)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would change existing functionality)
  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I have followed the code style of the project
  • I have added tests to cover my changes
  • I have updated the documentation accordingly
  • This PR is a result of pair or mob programming
  • Exceptions/Exclusions to coding standards (e.g. #noqa or #NOSONAR) are included within this Pull Request.

Sensitive Information Declaration

To ensure the utmost confidentiality and protect your and others privacy, we kindly ask you to NOT including PII (Personal Identifiable Information) / PID (Personal Identifiable Data) or any other sensitive data in this PR (Pull Request) and the codebase changes. We will remove any PR that do contain any sensitive information. We really appreciate your cooperation in this matter.

  • I confirm that neither PII/PID nor sensitive data are included in this PR and the codebase changes.

@Vox-Ben Vox-Ben requested a review from a team as a code owner February 10, 2026 22:13
@github-actions
Copy link

Deployment Complete

@github-actions
Copy link

Trivy gate: no Critical/High issues.

Trivy IaC (Terraform) Summary

Severity Count
CRITICAL 0
HIGH 0
MEDIUM 0
LOW 0
UNKNOWN 0
Findings (top 50)
Severity ID Title File

@github-actions
Copy link

Trivy gate: no Critical/High vulnerabilities.

Trivy Image Scan Summary

Image: 900119715266.dkr.ecr.eu-west-2.amazonaws.com/whoami:feature-gpcapim-265-x-request-id

Severity Count
CRITICAL 0
HIGH 0
MEDIUM 0
LOW 1
UNKNOWN 0
Findings (top 50)
Severity ID Package Installed Fixed Source
LOW CVE-2026-1703 pip 25.3 26.0 Python

@sonarqubecloud
Copy link

assert isinstance(headers["X-Request-ID"], str)
assert len(headers["X-Request-ID"]) >= 32
# Verify it's a valid UUID by trying to parse it
from uuid import UUID
Copy link
Contributor

Choose a reason for hiding this comment

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

Move to import block at the top of the file.

# Verify it's a valid UUID by trying to parse it
from uuid import UUID

UUID(headers["X-Request-ID"]) # Should not raise
Copy link
Contributor

Choose a reason for hiding this comment

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

To produce nicer error messages if/when the test fails:

Suggested change
UUID(headers["X-Request-ID"]) # Should not raise
try:
UUID(headers["X-Request-ID"])
except:
pytest.fail("Should not raise an error if this is genuinely a uuid")

Comment on lines +306 to +310
# X-Request-ID should be auto-generated as a UUID
assert "X-Request-ID" in headers
assert isinstance(headers["X-Request-ID"], str)
assert len(headers["X-Request-ID"]) >= 32
# Verify it's a valid UUID by trying to parse it
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO, these are unnecessary. The final assertion, UUID(headers["X-Request-ID"]) will check for these.

Calls ``GET /Patient/{nhs_number}``, which returns a single FHIR Patient
resource on success, then extracts a single :class:`PdsSearchResults`.

A new UUID is generated for the ``X-Request-ID`` header with each call.
Copy link
Contributor

Choose a reason for hiding this comment

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

You've stated this twice. I'm not sure it's need once.

Copy link
Contributor

Choose a reason for hiding this comment

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

I would parameterise the header test so that only a single assertion is made per test.

You could also patch the uuid module to return a yest value and assert for that.

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