Skip to content

Fix stale attachment IDs causing 404 errors in Emails section - #106

Open
MeloveGupta wants to merge 2 commits into
postgres:mainfrom
MeloveGupta:fix/email-attachments-link-mismatch
Open

MeloveGupta wants to merge 2 commits into
postgres:mainfrom
MeloveGupta:fix/email-attachments-link-mismatch

Conversation

@MeloveGupta

@MeloveGupta MeloveGupta commented Mar 2, 2026 •

Copy link
Copy Markdown

When the archives assign a new id to an attachment we already know about, the stored attachmentid and filename were never updated, because parse_and_add_attachments used get_or_create. That resulted in attachment links in the Emails section returning a 404. Now it uses update_or_create, so the attachment info is refreshed whenever the thread gets a new email.

MeloveGupta and others added 2 commits March 2, 2026 16:23
Change get_or_create to update_or_create in parse_and_add_attachments()
so that attachmentid and filename are refreshed when the mail archive
re-indexes attachments. Previously, defaults were only applied on record
creation, leaving stale IDs that pointed to non-existent attachments.

Add regression tests verifying attachment metadata is updated correctly.
The separate test file mostly covered behaviour that was already there.
The one new thing, refreshing a stale attachment id, is now checked as
part of the existing `refresh_single_thread` test, which exercises the
real code path. This also drops the unrelated reformatting of
`forms.py`, which is already on main.

This branch has not been deployed

No deployments
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.

2 participants