Bug 647080: [28.x] Fix: migrating a document attachment deletes shared Tenant Media - #10310
Merged
Jesper Schulz-Wedde (JesperSchulz) merged 1 commit intoAug 20, 2026
Conversation
) Backport to releases/28.x of microsoft/BCApps PR #10055. DA External Storage Impl.DeleteFromInternalStorage deleted the Tenant Media row unconditionally after moving an attachment to external storage. Tenant Media is shared storage: Document Attachment Mgmt.CopyAttachments copies the media reference rather than the bytes, so attachments copied onto posted documents all reference a single row. Deleting it on behalf of one attachment destroyed the content of every attachment copied from it, and those attachments were then skipped silently by UploadToExternalStorage. The fix only deletes the Tenant Media row when no other Document Attachment references it, index-backed by the existing key(Key2; "Document Reference ID") on table 1173. The build registration of the External Storage - Document Attachments test app from the original PR (build/groups.json and build/projects/Apps */.AL-Go/ settings.json) is intentionally omitted. Those files do not exist on releases/28.x, which instead uses wildcard testFolders ("src/Apps/W1/*/Test") in "build/projects/Apps (W1)/.AL-Go/settings.json" and therefore already picks the test app up, and has no build/groups.json. (cherry picked from commit 473bb07) Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Jesper Schulz-Wedde (JesperSchulz)
requested a review
from a team
as a code owner
August 17, 2026 13:45
Jesper Schulz-Wedde (JesperSchulz)
had a problem deploying
to
triage
August 17, 2026 13:45 — with
GitHub Actions
Failure
Jesper Schulz-Wedde (JesperSchulz)
had a problem deploying
to
triage
August 17, 2026 13:47 — with
GitHub Actions
Failure
Contributor
Author
|
Closing and reopening due to GitHub outage. |
Jesper Schulz-Wedde (JesperSchulz)
temporarily deployed
to
triage
August 18, 2026 07:02 — with
GitHub Actions
Inactive
Darrick (darjoo)
approved these changes
Aug 18, 2026
Jesper Schulz-Wedde (JesperSchulz)
enabled auto-merge (squash)
August 19, 2026 12:44
Aleyenda
approved these changes
Aug 20, 2026
Jesper Schulz-Wedde (JesperSchulz)
merged commit Aug 20, 2026
be24a6b
into
releases/28.x
96 of 104 checks passed
Jesper Schulz-Wedde (JesperSchulz)
deleted the
bugs/647080-28xBackportOf646505
branch
August 20, 2026 07:28
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.
Summary
Backport of #10055 to
releases/28.xfor the September release (28.5).DA External Storage Impl.DeleteFromInternalStoragedeleted theTenant Mediarow unconditionally after moving an attachment to external storage.Tenant Mediais shared storage:Document Attachment Mgmt.CopyAttachmentscopies the media reference rather than the bytes, so Vendor → Purchase Header → Purch. Inv. Header attachments all end up referencing a single row. Deleting that row on behalf of one attachment destroyed the content of every attachment copied from it.Those attachments were then skipped silently by
UploadToExternalStorage— theHasValue()guard sits aboveLogFeatureUsed(), so no telemetry was emitted — leavingStored Externally = false, a blankExternal File Pathand no internal content. Opening one raisesTenant Media does not exist. ID='{00000000-0000-0000-0000-000000000000}'fromGetAsTempBlob.On a production tenant migrating 5,226 attachments in one company, 4,810 uploaded successfully and 416 were silently skipped with their content destroyed.
The fix only deletes the
Tenant Mediarow when no otherDocument Attachmentreferences it, index-backed by the existingkey(Key2; "Document Reference ID")on table 1173.Work Item(s)
Fixes AB#647080 (backport of AB#646505)
Cherry-pick
Cherry-pick of 473bb07 (
-x). The AL change is byte-identical to the change merged tomain(2 files, 155 insertions, 7 deletions).One deliberate omission. The original PR also registered the External Storage - Document Attachments test app in the build, via
build/groups.jsonand 24 ×build/projects/Apps <CC>/.AL-Go/settings.json. Those files do not exist onreleases/28.x, which still uses the earlier build layout:build/groups.jsonon this branch (and no equivalent grouping file —AllExtensionsappears nowhere onreleases/28.x);build/projects/Apps (W1)/.AL-Go/settings.jsondeclarestestFolderswith wildcards (../../../src/Apps/W1/*/Test), which already matchessrc/Apps/W1/External Storage - Document Attachments/Test.So the test app is picked up automatically here and no registration change is needed.
Validation
Tests in
DA Ext. Storage Impl. Tests:DeleteFromInternalKeepsMediaSharedWithCopiedAttachmentTenant Mediasurvives; the copy keeps its contentDeleteFromInternalRemovesMediaWhenNotSharedUploadSucceedsForCopiedAttachmentAfterSourceIsMigratedThe first and third fail before the fix and pass after; the middle one passes both before and after, proving the fix does not stop reclaiming database space.