[Issue #8956] Remove orphaned attachments from submission zip file#9007
[Issue #8956] Remove orphaned attachments from submission zip file#9007mikehgrantsgov wants to merge 2 commits intomainfrom
Conversation
|
|
||
| # Only include attachments that are referenced in form responses. | ||
| # Orphaned attachments (not referenced anywhere) are excluded from the zip. | ||
| referenced_ids = _collect_referenced_attachment_ids(submission.application) |
There was a problem hiding this comment.
I'm probably missing some context on this work. The way it currently works is very intentional, I set it up to add all attachments to the ZIP regardless of whether they're referenced from a form because attachments don't need to be on a form in our system. I know we adjusted this in the XML because the legacy system does need that, but ours doesn't.
Is it causing issues for working with the old systems if there are are attachments present in the ZIP? If not, I'd strongly push back against this change as it's removing functionality that is intentionally different from the legacy approach. If a user uploads a file to an application without putting it on a form, what is the user experience to let them know that it will not be included when sent to a grantor?
Summary
Fixes #8956
Changes proposed
process_application_attachmentsnow calls_collect_referenced_attachment_ids()to determine which attachments are actually referenced in form responses before adding them to the submission ziptest_run_taskto reflect that attachments are orphaned and correctly excludedContext for reviewers
The orphan detection logic already existed in
create_attachment_mapping()to exclude unreferenced attachments from the XML, but wasn't being applied when building the zip. This change wires that same logic into the zip-building step so the zip and XML are consistent.Validation steps
See updated test cases.