Skip to content

NIAD-3467 Fixed undeleted logs bug#1286

Open
chiaramapellimt wants to merge 1 commit into
mainfrom
NIAD-3467-3
Open

NIAD-3467 Fixed undeleted logs bug#1286
chiaramapellimt wants to merge 1 commit into
mainfrom
NIAD-3467-3

Conversation

@chiaramapellimt
Copy link
Copy Markdown
Contributor

What

Add an empty list guard to canMergeCompleteBundle in InboundMessageMergingService to prevent premature bundle building when all attachment logs have been deleted.

Why

When the last attachment chunk of a large GP2GP patient record transfer arrives, checkAndMergeFileParts merges the fragments and then deletes their logs from the DB as cleanup. Immediately after, canMergeCompleteBundle checks those same logs to decide if the bundle is ready to build but they've just been deleted, so the list is empty. Java's allMatch() on an empty list always returns true, so the bundle gets built too early with no attachments.

The result is a blank patient record in Medicus after the transfer which is ofc wrong.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Internal change (non-breaking change with no effect on the functionality affecting end users)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • I have performed a self-review of my code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have updated the Changelog with details of my change in the UNRELEASED section if this change will affect end users
  • A corresponding change has been made to the Mapping Documentation repository

@chiaramapellimt chiaramapellimt requested a review from a team as a code owner June 3, 2026 15:24
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 3, 2026

Looks good. All 3 mutations in this change were killed.

class surviving killed
💯uk.nhs.adaptors.pss.translator.service.InboundMessageMergingService 0 3

See https://pitest.org

Copy link
Copy Markdown

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

Fixes a large-message GP2GP transfer edge case where canMergeCompleteBundle could return true when attachment logs are empty (due to cleanup), causing the bundle to be built prematurely without attachments.

Changes:

  • Added an empty-list guard in InboundMessageMergingService.canMergeCompleteBundle to return false when no undeleted attachment logs are found.
  • Added a unit test covering the “all attachment logs deleted” scenario.
  • Documented the fix in CHANGELOG.md.

Reviewed changes

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

File Description
gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/service/InboundMessageMergingService.java Prevents vacuous allMatch() truthiness on an empty log list from triggering early bundle creation.
gp2gp-translator/src/test/java/uk/nhs/adaptors/pss/translator/service/InboundMessageMergingServiceTests.java Adds a regression test asserting canMergeCompleteBundle returns false when logs are empty.
CHANGELOG.md Notes the bug fix and the user-visible impact (blank record after large transfers).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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