Systems and records
Attachment dataset manifest: scope belongs to the link, not the file
By SourceX Editorial · Updated
9 sections
Short answer
An attachment dataset manifest gives every attachment row four statuses of its own: file type, declared and detected; source link, meaning which record and through which relation; permitted scope, taken from that link because one stored file can sit on records with different access; and validation, covering presence, size and a named digest. On Redmine's 24 fixture attachments, these checks found 10 rows without a file and 2 files both open and restricted.
System export
Attachment dataset manifest
Key takeaways
- Key the attachment manifest on the file-to-record link, not the file hash, because one stored file can carry different scopes on different records.
- In Redmine's fixtures at commit 3d13ac3, all 24 attachment rows linked to an existing record, yet 10 pointed to files that were not there.
- One digest appeared on 8 rows declaring four different sizes, an inconsistency a manifest check can catch without opening a file.
- Two of the 5 shared stored files were open through one record and restricted through another, so scope has to be recorded per link.
- Carry declared and detected types side by side and name the digest algorithm on every row; 21 of the 24 fixture digests were MD5 length.
Why does an attachment need a manifest of its own?
Because an attachment is a separate object with its own storage, identity and access rules, and a record manifest that counts tickets or forms cannot say whether the files arrived, what they really are, or who was allowed to see them. Treating attachments as a column of the parent record is how deliveries end up with files that open but sit on the wrong record, or with files that were never cleared for the buyer.
Redmine's own code shows the separation. Its Attachment model belongs to a polymorphic container, so one attachments table serves many record types; its test fixtures attach files to issues, documents, wiki pages, versions, projects and forum messages. An attachment's visibility is delegated to that container, and an attachment with no container is visible only to its author. The digest is computed with SHA-256 when the file is stored, and a later step can point a new attachment row at an existing stored file when the digest, size and bytes match; the stored file is deleted only when no other attachment row still references it. Salesforce makes the same split with a dedicated object: a ContentDocumentLink row ties a file to the record where it is shared.
So the unit of an attachment manifest is the attachment row, meaning one file attached to one record through one relation. A stored file may appear on several rows, and the manifest has to say so rather than hide it behind a single checksum.
Four statuses every attachment row should carry
Each attachment row needs four statuses that can be set and checked independently: what the file is, where it came from, who may receive it, and whether it was verified. Collapse any two into one field and a buyer can no longer tell a missing file from a withheld one, or a wrong type from a corrupted file.
The table gives the allowed values and the evidence that sets each status:
| Status | What it records | Allowed values | Evidence that sets it |
|---|---|---|---|
| File type | Declared media type and the type detected from the bytes | agree, disagree, not declared, no file | Signature check on the delivered bytes against the declared type |
| Source link | Parent record, the relation, and the source system's attachment ID | resolves, dangling, unattached | Lookup of the parent ID in the delivered records of the same version |
| Permitted scope | The access or license scope that applies through this link, and where it came from | in scope, restricted, withheld, needs review | Parent's flags, the attachment's own flag, or the link's sharing setting |
| Validation | Presence, byte count and digest, with the digest algorithm named | verified, size mismatch, digest mismatch, missing | Recomputed size and digest on the delivered file |
Where scope lives: on the file, the link or the parent record
Scope can sit in three places, and a manifest has to record which one applied. Bugzilla puts it on the attachment: its API gives each attachment an is_private flag that restricts it to an insider group, alongside is_obsolete and is_patch flags, whatever the bug's own visibility. Redmine puts it on the parent: an attachment is visible when its container's attachments are visible, so a file on a private issue inherits that restriction, and the issue's is_private column defaults to false. The third place is the link between them. Salesforce models that link as its own object, ContentDocumentLink, and Redmine's attachment rows work the same way in practice, since several rows can point at one stored file while belonging to different records.
The practical rule follows from the last two. Key the manifest on the link, not the file hash, and store both the scope value and its source. A manifest keyed by digest has one row per stored file, so when the same bytes are attached openly in one place and under restriction in another, it can hold only one of the two answers.
Declared types need the same caution. Bugzilla forces the content type of an attachment marked as a patch to text/plain, and Redmine detects types from file contents with the filename as a hint, because many text formats cannot be identified from bytes alone. The WHATWG MIME Sniffing standard starts from the observation that many servers send a Content-Type that does not match the actual contents. A manifest should carry the declared type and the detected type side by side and flag disagreement, not overwrite one with the other.
What the checks found in Redmine's 24 fixture attachments
Every row looked complete, and the checks still found 10 rows with no file, one digest that cannot be true, and 2 stored files that were open and restricted at the same time. The run used Redmine's test fixtures at commit 3d13ac3: the 24 rows of attachments.yml, the fixture files they point to, and the fixture records of their containers. Fixtures are deliberately small test data, and several of these gaps are harmless there, so read the results as a demonstration of what each check can see, not as defects in Redmine.
All 24 rows resolved to an existing record across 6 container types, so a link-only check would pass the set. The file check did not: 10 rows point to stored files that are not in the fixture folder. The 14 files present matched their declared size and digest exactly. One digest value appears on 8 rows that declare four different sizes, 28, 280, 320 and 452 bytes; identical content cannot have different lengths, so that inconsistency is visible without opening any file. Digests are mixed, 21 of MD5 length and 3 of SHA-256 length, matching Redmine's note that digests created before version 3.4 were MD5.
Types and scope told their own stories. Of the 14 present files, 12 matched their declared type by signature; one declared application/octet-stream is a ZIP archive, and one with no declared type begins with a PostScript header. Four rows named .zip declare application/octet-stream. Seven rows inherit restricted scope, 6 from a private issue and 1 from a project that is not public. Five stored files serve 12 rows, and 2 of those 5 carry both scopes: the same diff file is attached to an open issue and, renamed private.diff, to a private one, while one ZIP archive is linked from an open issue, an open version, an open document and an issue in a non-public project.
The table lists each check, the rule the script applied and what it found:
| Check | Rule applied | Result on 24 rows | What it would mean in a delivery |
|---|---|---|---|
| Source link resolves | Container type and ID found in that container's fixture file | 24 of 24 resolve | Necessary, never sufficient on its own |
| File present | A file exists at the stored directory and filename | 14 present, 10 missing | Missing must be told apart from withheld |
| Size and digest | Byte count and MD5 or SHA-256 recomputed, chosen by digest length | 14 of 14 present files match | Only proves the bytes that arrived |
| Digest consistency | One digest value declared with more than one size | 1 digest on 8 rows, 4 sizes | Copied or placeholder metadata, found without the files |
| Declared against detected type | First bytes matched to PDF, PNG, GIF, JPEG, ZIP, WebP and PostScript signatures | 12 agree, 2 present files undeclared | Declared types cannot be trusted alone |
| Scope through each link | Private issue or non-public project makes the row restricted | 7 restricted; 2 shared files in both scopes | Scope must be keyed on the link |
The versioned attachment manifest, column by column
The manifest that survives these checks has one row per attachment link, carries both declared and detected facts, and records every change by version. Versioning matters because attachment rows change for reasons that leave the file untouched: a scope review withholds a file, a re-extraction replaces a digest with a stronger algorithm, or a parent record leaves the dataset and takes its attachments with it.
The columns below are the minimum; example values are illustrative:
| Column | What it holds | Illustrative value | Rule |
|---|---|---|---|
| attachment_row_id | One ID per file-to-record link | att-000418 | Unique within the manifest version |
| parent_record and relation | Record ID, record type and how the file attaches | ticket 88217, comment attachment | Must resolve in the same delivery version |
| stored_object and filename_shown | Content-addressed storage key and the name users saw | sha256 prefix 9f2c, invoice_march.pdf | Shared stored objects are listed, not merged |
| declared_type and detected_type | Source system's media type and the signature result | application/pdf, PDF | Disagreement is flagged, never overwritten |
| bytes, digest, digest_algorithm | Size and digest recomputed at extraction | 48211, 64 hex characters, SHA-256 | Algorithm named on every row |
| scope and scope_source | The scope through this link and where it came from | restricted, inherited from parent | Restricted or withheld rows are not shipped |
| validation_status | Outcome of presence, size and digest checks | verified | Missing and withheld are separate values |
| manifest_version and change_reason | Version that last changed the row, and why | v4, scope review withheld 3 rows | Every change appears in the version log |
Reproducibility checklist before attachments ship
Run the list on the delivered package in the buyer's intended format, after any renaming, redaction or repackaging, and keep the outputs with the manifest version:
Checklist · 9 items
- Count attachment rows, stored objects and parent records, and confirm the counts match the manifest header.
- Resolve every parent_record in the delivered records of the same version, with zero dangling links.
- Confirm each row's file is present, or that its status says withheld with a reason code.
- Recompute bytes and SHA-256 for every delivered file, and list any row whose source digest used another algorithm.
- Flag any digest declared with two or more sizes before opening a single file.
- Match the first bytes against known signatures and flag every disagreement with the declared type.
- Recompute scope through each link and confirm that no restricted or withheld row reached the package.
- For stored objects shared by several rows, confirm every row carries its own scope and that mixed-scope objects were reviewed.
- Diff the manifest against the previous version and confirm that every changed row has a change_reason.
0 of 9 ticked. Tick each item as you go.
Can a valid checksum still hide a broken attachment?
Yes. A checksum proves that the delivered bytes match the bytes someone hashed, and nothing about whether those bytes belong to the right record, are what their type claims, or were cleared for this buyer. In the Redmine run, every present file passed size and digest checks while scope, type and presence problems sat in plain view.
The algorithm matters too. RFC 6151 says the published attacks make MD5 imprudent where collision resistance is required, while an MD5 checksum used only to catch accidental errors remains acceptable. A manifest that inherits MD5 digests from an older system can still detect transfer corruption, but it should not be the evidence that a file was not swapped; recompute SHA-256 at extraction and name the algorithm on every row.
The strongest objection is cost: per-link rows and recomputed digests make large archives heavier to describe. The trade is small next to the alternative, because a file that leaks through a shared stored object, or a buyer who rejects a delivery when a sample shows renamed or mistyped files, costs more than the extra columns.
Methods note: the Redmine fixture run
Source: redmine/redmine at commit 3d13ac3 (2026-10-27), sparse clone of test/fixtures, app/models and db/migrate; no repository code was run. Rows are the 24 top-level entries of attachments.yml, parsed line by line, two-space-indented keys only; author fields were never used or printed. A stored file is files/<disk_directory>/<disk_filename>, or files/<disk_filename> when the directory is empty. Digests of 32 hex characters were checked as MD5 and of 64 as SHA-256, compared in lower case; Redmine's Attachment#digest_type treats any digest shorter than 64 characters as MD5, and no other length occurred.
Type: the first bytes of each present file were matched against PDF (%PDF-), PNG, GIF87a or GIF89a, JPEG (FF D8 FF), ZIP (PK 03 04), WebP (RIFF with WEBP at byte 8) and PostScript (%!PS-Adobe-) signatures, the PDF, ZIP and PostScript patterns as listed in the WHATWG standard; declared text types agree when no signature matches and the file has no NUL byte; application/octet-stream and empty types count as not declared. Extensions were compared with a fixed table of ten. Scope: a row is restricted when its container is an issue whose is_private is true (missing means false, the column default) or when the container's project has is_public false; wiki pages reach their project through wikis and messages through boards.
A shared stored file is one path used by two or more rows; a placeholder digest is one value declared with two or more sizes; a mixed-scope file is a shared file with both restricted and open rows. Limits: fixtures are test data built to exercise code paths, so missing files and copied digests are not production defects; the signature table covers only the types present here. The script is bin/redmine_attachment_manifest.py and its per-row output, without author fields, is bin/redmine_out.txt in the analysis folder.
Asking for attachment-level evidence in a data request
SourceX sources datasets on request, and its request form already asks for format, de-identification requirements and additional specifications. Use those fields to say whether attachments are in scope, which parent records and relations matter, the digest algorithm you expect, and the attachment checks your acceptance test will run, so the files can be assessed with the records rather than after them.
On the supply side, the company agrees what is included and on what terms, and signs, before anything is handed over; the live how-it-works page says each deal's Dataset Deal Confirmation fixes the exact dataset, rights and processing route. Attachments with their own scope are part of what that dataset definition has to name.
Frequently asked questions
What is an attachment dataset manifest?
It is a file-level inventory with one row per attachment link: the parent record and relation, the stored object, declared and detected type, size and digest with its algorithm, the permitted scope and where it came from, a validation status and the manifest version that last changed the row. It travels with the delivery so a buyer can recheck every attachment.
Why can't the parent record's permissions cover its attachments?
Sometimes they do, but not always. Bugzilla gives each attachment its own private flag, Redmine inherits visibility from the parent, and stored files can be shared across records. In Redmine's fixtures, 2 stored files were open through one record and restricted through another, so scope has to be recorded per link.
Should an attachment manifest use MD5 or SHA-256?
Name the algorithm on every row and recompute SHA-256 at extraction where you can. RFC 6151 accepts MD5 for catching accidental errors but not where collision resistance is needed. Older systems often hold MD5 digests, as Redmine did before version 3.4.
How should a manifest record an attachment that was withheld?
Keep the row, set its validation status to withheld rather than missing, add a reason code such as scope review or privacy, and leave the file out of the package. A buyer can then reconcile counts without receiving the file or mistaking it for a loss.
Is the declared MIME type enough to know what a file is?
No. Source systems guess, force or omit types, and the WHATWG MIME Sniffing standard notes that declared types often do not match contents. Check the first bytes against known signatures and keep both values; in Redmine's fixtures one file declared as octet-stream was a ZIP archive.
Sources
- Redmine's Attachment model belongs to a polymorphic container, delegates visibility to that container (unattached files are visible only to their author), computes a SHA-256 digest, detects content types with the filename as a hint, reuses an existing stored file when digest, size and bytes match, and labels digests shorter than 64 characters MD5, created before Redmine 3.4. Source
- Redmine's attachments fixture lists 24 attachment rows with container type and ID, stored directory and filename, size, digest and content type. Source
- Redmine's migration adds the issues is_private column as a boolean defaulting to false. Source
- Bugzilla's attachment API documents per-attachment bug_id, size, content_type, is_private (restricted to the insidergroup), is_obsolete, is_patch and flags, and forces the content type of patches to text/plain. Source
- The WHATWG MIME Sniffing standard says many HTTP servers supply a Content-Type that does not match the actual contents, and lists byte signatures including %PDF-, PK 03 04 and %!PS-Adobe-. Source
- Salesforce's ContentDocumentLink object links a file to the place where it is shared; each link references the file by ContentDocumentId and the record by LinkedEntityId. Source
- RFC 6151 says published attacks make MD5 imprudent where collision resistance is required, while an MD5 checksum used only to protect against errors remains acceptable. Source
- SourceX's request page says datasets are sourced on request and its form asks for format, de-identification requirements and additional specifications. Source
- SourceX's how-it-works page says the supplier signs before any data is delivered and that each Dataset Deal Confirmation fixes the exact dataset, rights, processing route and deadlines. Source
Tell us what data you need
Share scope, volume, format, timing and licensing needs. Datasets are sourced on request.