Fix canMergeCompleteBundle returning true for empty attachment logs#1283
Closed
chiaramapellimt wants to merge 4 commits into
Closed
Fix canMergeCompleteBundle returning true for empty attachment logs#1283chiaramapellimt wants to merge 4 commits into
chiaramapellimt wants to merge 4 commits into
Conversation
|
Images built and published to ECR using a Build Id of PR-1115-6c39583 |
There was a problem hiding this comment.
Pull request overview
Fixes a bug in the GP2GP translator’s large-message flow where canMergeCompleteBundle could return true when there are no undeleted attachment logs (because Stream.allMatch(...) is vacuously true on an empty stream), leading to premature bundle creation with missing attachments.
Changes:
- Add an explicit empty-list guard to
InboundMessageMergingService.canMergeCompleteBundle. - Update/extend unit tests to cover the empty/“all deleted” attachment log scenario and clarify an existing test name.
- Document the fix in
CHANGELOG.md.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| gp2gp-translator/src/main/java/uk/nhs/adaptors/pss/translator/service/InboundMessageMergingService.java | Adds an undeletedLogs.isEmpty() guard to prevent vacuous allMatch() returning true. |
| gp2gp-translator/src/test/java/uk/nhs/adaptors/pss/translator/service/InboundMessageMergingServiceTests.java | Adds/renames tests around canMergeCompleteBundle, including the “logs deleted/empty” case. |
| CHANGELOG.md | Adds an Unreleased note describing the bug fix (should be categorized under “Fixed”). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
85c83d8 to
c75b8b3
Compare
|
Looks good. All 3 mutations in this change were killed.
|
This reverts commit e5fb25f.
c75b8b3 to
2a0f1ae
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Add an empty list guard to
canMergeCompleteBundleinInboundMessageMergingServiceto prevent premature bundle building when all attachment logs have been deleted. Also adds a new unit testWhen_AllAttachmentLogsDeleted_CanMergeCompleteBundle_Expect_ReturnFalseand renamesWhen_AllUploadsComplete_CanMergeCompleteBundle_Expect_ReturnTruetoWhen_AllUploadsComplete_AndLogsNotEmpty_CanMergeCompleteBundle_Expect_ReturnTruefor clarity.Why
When the last attachment chunk of a large GP2GP patient record transfer arrives,
checkAndMergeFilePartsmerges the fragments and then deletes their logs from the DB as cleanup. Immediately after,canMergeCompleteBundlechecks those same logs to decide if the bundle is ready to build but they've just been deleted, so the list is empty. Java'sallMatch()on an empty list always returnstrue, so the bundle gets built too early with no attachments.The result is a blank patient record in Medicus after the transfer.
Type of change
Please delete options that are not relevant.
Checklist: