Sending documents: sent_to is not cut to its 250-character column, so a long title and employer fail on PostgreSQL #513
Labels
No labels
accessibility
authentication
breaking change
bug
documentation
enhancement
interface
internationalisation
observability
performance
security
tier
1
tier
2
tier
3
tier/4
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Postulo/postulo#513
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Found on 2026-09-29 in a read-only review of postulo at
95348908d, by comparing the length of whatsent_to()writes with the column it writes into.Checked again on 2026-10-01 against
mainat0a5cad587: still present. The code is now atdocuments/rendering.py:536-549(sent_to), called fromsnapshot_cv(rendering.py:646) andsnapshot_letter(rendering.py:709), with_file_and_saveatrendering.py:518-533; the column is atdocuments/models.py:644,JobPosting.titleatjobs/models.py:877andCompany.nameatjobs/models.py:248. The backfill migration has not moved.sent_to()writes "%(role)s at %(company)s" without cutting it to length. A posting's title may be 250 characters and a company's name 200, butRenderedDocument.sent_tois aCharField(max_length=250). The backfill migration that first filled the column cuts to 250; the live path does not. On PostgreSQL the insert raisesDataError; SQLite does not enforce the length, so the default setup is unaffected.documents/rendering.py:562-575,sent_to:gettext("%(role)s at %(company)s") % {...}with no truncation; called fromsnapshot_cv(rendering.py:672) andsnapshot_letter(rendering.py:735).documents/models.py:616:sent_to = models.CharField(_("sent to"), max_length=250, ...).jobs/models.py:874(JobPosting.title, 250) andjobs/models.py:245(Company.name, 200).documents/migrations/0009_backfill_sent_to_and_upload_checksums.py:30: the backfill does[:250].documents/rendering.py:544-559,_file_and_save: the PDF is written before the row is saved.sent_documentserrand ends in "Something went wrong. The server log has the details.", nothing is attached, and each retry fails the same way while leaving another PDF on disk that no row points at.RenderedDocument._meta.get_field("sent_to").max_lengthinsent_to(), withTruncator(...).chars()so it ends with an ellipsis, as the backfill already cuts.RenderedDocument.title(250) deserves the same guard, sincedocument_title()starts from a full name that can reach 301 characters.Done when
tests/test_document_record.pybuilds an application with a 250-character title and a 200-character company, callsrendering.sent_to(), and asserts that the result fits the column; it fails today.