Skip to content

Conversation

@simonlabarere
Copy link
Contributor

@simonlabarere simonlabarere commented Feb 3, 2026

Description

Component to trigger daily reports for all the senders.

Notes:

Testing

image image

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
  • If I have used the 'skip-trivy-package' label I have done so responsibly and in the knowledge that this is being fixed as part of a separate ticket/PR.

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.

@simonlabarere simonlabarere requested review from a team as code owners February 3, 2026 09:17
"dependencies": {
"aws-lambda": "^1.0.7",
"digital-letters-events": "^0.0.1",
"p-limit": "^3.1.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

I probably missed it, but is it used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, I'll remove it!

apim_keystore_s3_bucket = "nhs-${var.aws_account_id}-${var.region}-${var.environment}-${var.component}-static-assets"
unscanned_files_bucket = local.acct.additional_s3_buckets["digital-letters_unscanned-files"]["id"]
ssm_mesh_prefix = "/${var.component}/${var.environment}/mesh"
ssm_senders_prefix = "/${var.component}/${var.environment}/senders"
Copy link
Contributor

Choose a reason for hiding this comment

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

is more clear this way and we could reuse it in module_lambda_ttl_create.tf and module_lambda_core_notifier.tf

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!

@gareth-allan gareth-allan self-assigned this Feb 3, 2026
CVE-2024-49761 # https://avd.aquasec.com/nvd/cve-2024-49761 ## latest Jekyll Webpack (0.2.7) installs old version of rexml
CVE-2024-47220 # https://avd.aquasec.com/nvd/cve-2024-47220 ## latest lint_roller (1.1.0) installs old version of rexml
CVE-2024-7254 # https://avd.aquasec.com/nvd/cve-2024-7254 ## latest Jekyll Webpack (0.2.7) installs old version of google-protobuf
CVE-2026-25128
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we want to merge this now the fix is in.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes agreed. I should have used the tag to skip the check.

Comment on lines +50 to +53
const senderIds = parsedEvents.map((event) => event.data.senderId);
expect(senderIds).toContain('2b8ebb33-8b33-49bd-949e-c12e22d25320');
expect(senderIds).toContain('f017669b-6da4-4576-9d59-3d2b7f005ae2');
expect(senderIds).toContain('67403568-166e-41d0-900a-1f31fe93a091');
Copy link
Contributor

Choose a reason for hiding this comment

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

These should probably use the constants from tests-constants.ts, right?

Also, it might be worth a comment to explain why we expect the event to contain these sender IDs (I believe it's because we've put them into the sender config in SSM). It wasn't immediately clear to me what these IDs were.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll replace the hardcoded IDs with constants but isn't the name of the test a good clue for what's happening?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, that's a fair point. It was probably more the fact that I reviewed it late in the day than the code being unclear!

@@ -0,0 +1,29 @@
{
"dependencies": {
"aws-lambda": "^1.0.7",
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think you're using aws-lambda (or @types/aws-lambda) in this function.

Comment on lines +12 to +14
"@types/lodash": "^4.17.20",
"aws-sdk-client-mock": "^4.1.0",
"aws-sdk-client-mock-jest": "^4.1.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure you're using any of these dependencies either.

Suggested change
"@types/lodash": "^4.17.20",
"aws-sdk-client-mock": "^4.1.0",
"aws-sdk-client-mock-jest": "^4.1.0",

"aws-sdk-client-mock": "^4.1.0",
"aws-sdk-client-mock-jest": "^4.1.0",
"jest": "^29.7.0",
"jest-mock-extended": "^3.0.7",
Copy link
Contributor

Choose a reason for hiding this comment

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

Or jest-mock-extended!

Suggested change
"jest-mock-extended": "^3.0.7",

Comment on lines +36 to +56
it('should calculate yesterday date range correctly', async () => {
const mockDate = new Date('2024-01-15T12:00:00.000Z');
jest.setSystemTime(mockDate);

mockSenderManagement.listSenders.mockResolvedValue([]);
mockEventPublisher.sendEvents.mockResolvedValue([]);

const handler = createHandler({
logger: mockLogger,
senderManagement: mockSenderManagement,
eventPublisher: mockEventPublisher,
});

await handler();

expect(mockLogger.debug).toHaveBeenCalledWith({
description: 'Calculated yesterday date range',
yesterdayStart: '2024-01-14T00:00:00.000Z',
yesterdayEnd: '2024-01-14T23:59:59.999Z',
});
});
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this test would be better verifying the value of the data.reportPeriodStartTime and data.reportPeriodEndTime fields in the return value of handler(), rather than what was logged. Ultimately, it's the return values that are used.

Comment on lines +173 to +187
it('should handle event publisher errors', async () => {
const mockSenders = [{ senderId: 'sender-1' }] as unknown as Sender[];
const error = new Error('Failed to publish events');

mockSenderManagement.listSenders.mockResolvedValue(mockSenders);
mockEventPublisher.sendEvents.mockRejectedValue(error);

const handler = createHandler({
logger: mockLogger,
senderManagement: mockSenderManagement,
eventPublisher: mockEventPublisher,
});

await expect(handler()).rejects.toThrow('Failed to publish events');
});
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think that sendEvents throws an error. I think it reutrns a list of failed events instead.

Copy link
Contributor

Choose a reason for hiding this comment

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

This has a lot more changes in it than I'd expect, given the changes you've made to the package.json files. It also appears to undo the fix for the fast-xml-parser vulnerability (from a local run of npm audit at least).

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