Skip to content

Fix/bulk send file attachments missing - #2958

Open
whabanks wants to merge 15 commits into
mainfrom
fix/bulk-send-file-attachments-missing
Open

Fix/bulk send file attachments missing#2958
whabanks wants to merge 15 commits into
mainfrom
fix/bulk-send-file-attachments-missing

Conversation

@whabanks

@whabanks whabanks commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Summary | Résumé

This PR fixes an issue where file attachment metadata was not persisted to notification.personalisation for notifications belonging to a job.

When performing a one-off send, admin attaches file metadata to the notification's personalisation before calling API. This change ensures that the same occurs for notifications sent during a bulk job. Because the job CSV only contained user provided columns, we weren't writing the template attachment metadata into each notification's personalisation, resulting in the notification history page failing to display attachment metadata for notifications belonging to a job.

  • Added _persist_template_attachment_metadata to send_to_providers.py. send_email_to_provider calls to update the personalisation dict prior to persisting the status -> sending update to the db. This method will only add to metadata if it does not yet exist and thus should not affect the one-off sending flow.
  • Added file_size to the Redis cache key for job attachments.

Related Issues | Cartes liées

Test instructions | Instructions pour tester la modification

  1. Hook your local up to staging (Admin + API) and run document download locally
  2. Send a bulk job
  • Confirm you received the file attachments in the emails you received
  1. From the dashboard navigate to one of the notifications belonging to the job
  • Note that the file attachments & size are listed below the content block

Release Instructions | Instructions pour le déploiement

None.

Reviewer checklist | Liste de vérification du réviseur

  • This PR does not break existing functionality.
  • This PR does not violate GCNotify's privacy policies.
  • This PR does not raise new security concerns. Refer to our GC Notify Risk Register document on our Google drive.
  • This PR does not significantly alter performance.
  • Additional required documentation resulting of these changes is covered (such as the README, setup instructions, a related ADR or the technical documentation).

⚠ If boxes cannot be checked off before merging the PR, they should be moved to the "Release Instructions" section with appropriate steps required to verify before release. For example, changes to celery code may require tests on staging to verify that performance has not been affected.

whabanks added 2 commits July 20, 2026 14:16
Fixed an issue where bulk jobs were not fetching template attachment
metadata prior to sending. This fixes two issues:
1. Files weren't attached to email notifications when sent
2. Metadata wasn't available for the front end to display file
   attachment names when viewing notification history from the dashboard
When performing a one-off send, admin attaches file metadata to the
notification's personalisation before calling API. This change ensures
that the same occurs for notifications sent during a bulk job. Because
the job CSV only contained user-provided columns, we weren't writing the
template attachment metadata into each notification's personalisation,
resulting in the history page failing to display attachments for
notifications belonging to a job
- Added `_persist_template_attachment_metadata` to `send_to_providers`
  where it is called during `send_email_to_provider` to update the
personalisation
@whabanks
whabanks requested a review from jimleroyer as a code owner July 21, 2026 17:27
Copilot AI review requested due to automatic review settings July 21, 2026 17:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes bulk-job email notifications missing template attachment metadata in notification.personalisation, which breaks attachment display on the notification history page.

Changes:

  • Adds file_size to cached/DB template-file metadata used during bulk sends.
  • Introduces _persist_template_attachment_metadata and calls it from send_email_to_provider to populate _file_N personalisation entries for bulk notifications.
  • Adds tests covering persistence behavior and integration with send_email_to_provider.

Reviewed changes

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

File Description
app/delivery/send_to_providers.py Adds file_size to template file metadata, introduces metadata persistence helper, and calls it during email send flow.
app/celery/tasks.py Includes file_size when pre-caching template file metadata for jobs.
tests/app/delivery/test_template_attachments.py Adds unit + integration tests for persisting template attachment metadata into notification personalisation.

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

Comment thread app/delivery/send_to_providers.py Outdated
Comment thread tests/app/delivery/test_template_attachments.py Outdated

@andrewleith andrewleith left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM - I can see the attachment list on a bulk notification history page now!

@jzbahrai
jzbahrai enabled auto-merge (squash) August 11, 2026 15:23
@jzbahrai
jzbahrai disabled auto-merge August 11, 2026 15:23
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.

4 participants