Skip to content

[Issue #8956] Remove orphaned attachments from submission zip file#9007

Open
mikehgrantsgov wants to merge 2 commits intomainfrom
mikehgrantsgov/8956-fix-orphaned-attachments-zip-file
Open

[Issue #8956] Remove orphaned attachments from submission zip file#9007
mikehgrantsgov wants to merge 2 commits intomainfrom
mikehgrantsgov/8956-fix-orphaned-attachments-zip-file

Conversation

@mikehgrantsgov
Copy link
Collaborator

Summary

Fixes #8956

Changes proposed

  • process_application_attachments now calls _collect_referenced_attachment_ids() to determine which attachments are actually referenced in form responses before adding them to the submission zip
  • Orphaned attachments (uploaded but not referenced in any form field) are skipped with a warning log
  • Updated test_run_task to reflect that attachments are orphaned and correctly excluded
  • Added test case to cover behavior

Context 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.


# 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)
Copy link
Collaborator

Choose a reason for hiding this comment

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

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?

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.

BUG: Orphaned attachments are included in the submission zip file

2 participants