Skip to content

fix(ingest): use compatible MIME refinements after byte detection - #608

Merged
wesm merged 2 commits into
kenn-io:mainfrom
rodboev:pr/ingest-byte-first-mime
Oct 2, 2026
Merged

wesm merged 2 commits into
kenn-io:mainfrom
rodboev:pr/ingest-byte-first-mime

Conversation

@rodboev

@rodboev rodboev commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Docbank now identifies a JPEG by its contents, so it's stored as a JPEG even after another Windows program changes what the .jpg extension means in the registry. Before, Docbank trusted that registry entry, so after such a change it stored JPEGs under the wrong type and photo features refused them.

Local imports, docbank put and load-file packages now decide a file's type from its first bytes. The extension decides only when the bytes don't identify the type, or when it names a more specific type the bytes fit, such as .csv on plain text. YAML and TeX files now count as text, so their contents are searchable.

Camera RAW files look like TIFFs from their bytes, so TIFF bytes with a Sony, Canon, Nikon or DNG extension get that RAW type, and XMP sidecars get the XMP type. These rules ignore the registry, since that's what got changed. Files already stored keep the type they were stored with.

Refs #561

@roborev-ci

roborev-ci Bot commented Sep 25, 2026

Copy link
Copy Markdown

roborev: Combined Review (72268eb)

Verdict: No findings at or above medium severity.


Reviewers: 2 done | Synthesis: codex | Total: 5m54s

@roborev-ci

roborev-ci Bot commented Sep 25, 2026

Copy link
Copy Markdown

roborev: Combined Review (3e3cb6e)

Verdict: No findings at or above medium severity.


Reviewers: 2 done | Synthesis: codex, 4s | Total: 5m33s

@roborev-ci

roborev-ci Bot commented Sep 25, 2026

Copy link
Copy Markdown

roborev: Combined Review (8c55e18)

Verdict: No findings at or above medium severity.


Reviewers: 2 done | Synthesis: codex | Total: 6m34s

@rodboev
rodboev force-pushed the pr/ingest-byte-first-mime branch from 8c55e18 to 3da8dd7 Compare September 25, 2026 18:59
@roborev-ci

roborev-ci Bot commented Sep 25, 2026

Copy link
Copy Markdown

roborev: Combined Review (3da8dd7)

Verdict: Changes require fixes for 1 finding.

Medium

  • internal/ingest/mime.go:153: Files with an .apng suffix are stored as image/apng, but the visual preview producer only dispatches image/png, causing valid APNG inputs to receive unsupported_media_type instead of using the PNG preview path. Handle image/apng in the PNG preview branch or retain image/png for this suffix, and add an end-to-end preview assertion for .apng inputs.

    Reported by: codex


Reviewers: 2 done | Synthesis: codex, 5s | Total: 6m55s

@roborev-ci

roborev-ci Bot commented Sep 25, 2026

Copy link
Copy Markdown

roborev: Combined Review (3a4152a)

Verdict: Changes require fixes for 1 finding.

Medium

  • cmd/docbank/put.go:54: putSourceMIME classifies the first 512 bytes before a separate hashing pass, so an in-place source modification between passes can cause the daemon to store a MIME type for different bytes than those hashed and uploaded.

    Fix: Capture the prefix during hashing and derive MIME from that exact hashed prefix, or fingerprint and revalidate the source before submitting the replacement.


Reviewers: codex, codex (security) | Synthesis: codex, 4s | Total: 7m41s

@roborev-ci

roborev-ci Bot commented Sep 25, 2026

Copy link
Copy Markdown

roborev: Combined Review (acf43b8)

Verdict: No findings at or above medium severity.


Reviewers: codex, codex (security) | Synthesis: codex | Total: 8m8s

@rodboev
rodboev requested a review from wesm September 26, 2026 01:53
@wesm wesm self-assigned this Oct 2, 2026
- fix(ingest): retain extensions for content-guessed MIME types (kenn-io#561)
- Detect local MIME types from file bytes first
- fix(ingest): share byte-first MIME detection across local writers
- fix(ingest): preserve MIME consumer behavior
- Use rejected package bytes and source-built MinIO in CI
- Rerun CI with current MinIO setup
- Use PNG MIME for APNG suffixes
- Capture MIME from the replacement hash pass
- Test automatic put MIME and content receipt

Generated with Codex
Co-authored-by: Codex <noreply@openai.com>
@wesm
wesm force-pushed the pr/ingest-byte-first-mime branch from acf43b8 to 3afa868 Compare October 2, 2026 02:36
@roborev-ci

roborev-ci Bot commented Oct 2, 2026

Copy link
Copy Markdown

roborev: Combined Review (3afa868)

Verdict: No findings at or above medium severity.


Reviewers: 2x codex, codex (security) | Synthesis: codex | Total: 12m36s

Photo commands and package exports need image content in their fixtures.
The old JPEG and TIFF placeholders contained plain text and relied on
filename extensions to identify them. Byte-first MIME detection correctly
classifies those placeholders as text, so the tests no longer reach the
photo and image-export behavior they are meant to exercise.

Generate small synthetic JPEG and TIFF images while retaining the existing
workflow assertions and distinct page content.

Generated with Codex
Co-authored-by: Codex <noreply@openai.com>
@roborev-ci

roborev-ci Bot commented Oct 2, 2026

Copy link
Copy Markdown

roborev: Combined Review (3ddfcfa)

Verdict: No findings at or above medium severity.


Reviewers: 2x codex, codex (security) | Synthesis: codex, 5s | Total: 15m7s

@wesm
wesm merged commit 4b7a48a into kenn-io:main Oct 2, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants