Skip to content

[HOTE-803] feat: Remove undici package#338

Merged
lewisbirks merged 13 commits intomainfrom
feature/hote-803/update-npm-deps-new-features
Apr 13, 2026
Merged

[HOTE-803] feat: Remove undici package#338
lewisbirks merged 13 commits intomainfrom
feature/hote-803/update-npm-deps-new-features

Conversation

@mikeeq
Copy link
Copy Markdown
Collaborator

@mikeeq mikeeq commented Apr 10, 2026

Description

Context

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 am familiar with the contributing guidelines
  • 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

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.

Copilot AI review requested due to automatic review settings April 10, 2026 15:30
@mikeeq mikeeq changed the title [HOTE-803] Update undici package to 8.x [HOTE-803] feat: Update undici package to 8.x Apr 10, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the lambdas/ package to use undici 8.x and adjusts the shared HTTP client wrapper to ensure Agent dispatchers remain compatible at runtime while preserving existing unit-test mocking behavior.

Changes:

  • Bump undici dependency from 7.24.7 to 8.0.2 in lambdas/.
  • Update FetchHttpClient to route requests through an internal doFetch() helper, using undici’s fetch when a custom Agent dispatcher is configured.
  • Regenerate lambdas/package-lock.json to reflect the new dependency graph and engine requirements.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
lambdas/src/lib/http/http-client.ts Uses undici’s fetch when a custom Agent dispatcher is present; otherwise uses global fetch to keep existing Jest mocks working.
lambdas/package.json Updates undici to 8.0.2.
lambdas/package-lock.json Lockfile updates for undici@8.0.2 and transitive dependencies/engines.
Files not reviewed (1)
  • lambdas/package-lock.json: Language not supported

@lewisbirks
Copy link
Copy Markdown
Contributor

@mikeeq one thing to check would be if we actually need undici or if it can be removed. I know that it is used but is it used sensibly or can we just get rid of the reason we are using it.

Copilot AI review requested due to automatic review settings April 13, 2026 10:21
@mikeeq mikeeq force-pushed the feature/hote-803/update-npm-deps-new-features branch from 19121b6 to ced04d8 Compare April 13, 2026 10:22
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 13, 2026

UI Coverage Report

Lines Statements Branches Functions
Coverage: 95%
95.66% (5732/5992) 87.58% (684/781) 87.86% (210/239)

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

Files not reviewed (1)
  • lambdas/package-lock.json: Language not supported

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 13, 2026

Lambdas Coverage Report

Lines Statements Branches Functions
Coverage: 98%
98.57% (1449/1470) 93.12% (420/451) 96.65% (231/239)

lewisbirks and others added 2 commits April 13, 2026 11:59
`undici` was added as a dependency solely to provide an `Agent` that could disable TLS certificate
verification (`rejectUnauthorized: false`) when making outbound HTTP requests via the native
`fetch` API. This was used in `FetchHttpClient` and surfaced through the
`POSTCODE_LOOKUP_REJECT_UNAUTHORIZED` environment variable on the postcode-lookup lambda.

Investigation showed the option served no purpose in any environment:

- **Locally**, the postcode lookup target (`POSTCODE_LOOKUP_BASE_URL`) resolves to WireMock over
  plain HTTP (`http://wiremock:8080`), so TLS is never negotiated and `rejectUnauthorized` has no
  effect.
- **In production**, the environment variable is absent, causing the expression
  `retrieveOptionalEnvVariable("POSTCODE_LOOKUP_REJECT_UNAUTHORIZED") === "true"` to evaluate to
  `false` — meaning TLS verification was silently disabled for every OS Places API call in
  production.

The `undici` dependency, the `rejectUnauthorized` option on `FetchHttpClient`, the corresponding
fields on `PostcodeLookupClientConfig` and `PostcodeLookupEnvVariables`, and the Terraform env var
have all been removed. `FetchHttpClient` now uses the native `fetch` API directly with no
dispatcher override.

Signed-off-by: lewisbirks <lewis.birks1@nhs.net>
Copilot AI review requested due to automatic review settings April 13, 2026 11:24
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated 1 comment.

Files not reviewed (1)
  • lambdas/package-lock.json: Language not supported

@lewisbirks lewisbirks changed the title [HOTE-803] feat: Update undici package to 8.x [HOTE-803] feat: Remove undici package Apr 13, 2026
@sonarqubecloud
Copy link
Copy Markdown

@lewisbirks lewisbirks enabled auto-merge (squash) April 13, 2026 11:33
@lewisbirks lewisbirks merged commit 91bacc1 into main Apr 13, 2026
13 checks passed
@lewisbirks lewisbirks deleted the feature/hote-803/update-npm-deps-new-features branch April 13, 2026 13:07
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.

3 participants