GRI-1877: wire PDF upload to the page converter (signage #15b) #106

Merged
vivy merged 1 commit from feature/GRI-1877-pdf-upload-wiring into dev 2026-11-10 05:37:57 +00:00
Member

What

Wires POST /api/v1/media's PDF path to the page converter (crates/server/src/pdf.rs, GRI-1868 / signage #15a), closing signage #15b.

  • handlers::convert_pdf_upload replaces the pdf_not_yet_supported stub: it renders the PDF to a scratch directory, and only once every page has rendered does it write the original into the media directory and insert its media row (kind = "document", pdf_pages set to the page count), then one more media row per page (kind = "document_page"). A PDF the converter cannot parse leaves no catalog entry at all (AC-3-06).
  • media_kind_check (migration 0003_document_page_media_kind.sql) is widened to allow document_page, matching what GET /media and a document_page playlist item (playlist_items.kind, already in the schema) both expect.
  • packaging/server/Dockerfile installs poppler-utils, which pdf.rs shells out to (pdftoppm) — without it the deployed server would refuse every PDF with PdfError::ToolMissing, the same failure this issue exists to remove.
  • media_integration.rs's a_pdf_upload_is_refused_until_the_converter_is_wired_in (added alongside the stub on GRI-1874) is replaced by an_unparseable_pdf_upload_is_refused, since its assertion — that every PDF is refused with unsupported_media_type — is exactly the behaviour this issue removes. The new test keeps the same coverage (a PDF the converter can't parse still gets a clean 4xx) under the new error code (invalid_pdf).

Known gap: ac_3_03 stays #[ignore]d

media_acceptance_integration.rs::ac_3_03_uploading_a_multi_page_pdf_creates_one_document_page_item_per_page needs a working pdftoppm to actually split a real PDF. This build host has no poppler-utils installed (confirmed: pdftoppm not on PATH, no sudo to install it), so I can't verify the real-conversion path end to end here, and I did not touch that test — it isn't mine to un-ignore blind. pdf.rs's own renders_a_real_two_page_pdf_with_default_options is #[ignore]d for the identical reason and was left that way when GRI-1868 landed.

Everything that doesn't need a real pdftoppm passes: cargo test -p server (all gates via scripts/local-gates.sh), including ac_3_06 (corrupt PDF → clean 4xx, no items) and the full pdf.rs unit suite against a fake converter script.

Flagging to the CTO/System Administrator separately: the build host and (likely) the CI runner need poppler-utils, the same package I added to the runtime image, before ac_3_03 can be un-ignored for real.

How verified

SIGNAGE_TEST_DATABASE_URL=postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable \
  ./scripts/local-gates.sh --rust-only   # all gates pass
./scripts/local-gates.sh --frontend-only # all gates pass (untouched by this change)
## What Wires `POST /api/v1/media`'s PDF path to the page converter (`crates/server/src/pdf.rs`, GRI-1868 / signage #15a), closing signage #15b. - `handlers::convert_pdf_upload` replaces the `pdf_not_yet_supported` stub: it renders the PDF to a scratch directory, and only once every page has rendered does it write the original into the media directory and insert its `media` row (`kind = "document"`, `pdf_pages` set to the page count), then one more `media` row per page (`kind = "document_page"`). A PDF the converter cannot parse leaves no catalog entry at all (AC-3-06). - `media_kind_check` (migration `0003_document_page_media_kind.sql`) is widened to allow `document_page`, matching what `GET /media` and a `document_page` playlist item (`playlist_items.kind`, already in the schema) both expect. - `packaging/server/Dockerfile` installs `poppler-utils`, which `pdf.rs` shells out to (`pdftoppm`) — without it the deployed server would refuse every PDF with `PdfError::ToolMissing`, the same failure this issue exists to remove. - `media_integration.rs`'s `a_pdf_upload_is_refused_until_the_converter_is_wired_in` (added alongside the stub on GRI-1874) is replaced by `an_unparseable_pdf_upload_is_refused`, since its assertion — that every PDF is refused with `unsupported_media_type` — is exactly the behaviour this issue removes. The new test keeps the same coverage (a PDF the converter can't parse still gets a clean 4xx) under the new error code (`invalid_pdf`). ## Known gap: `ac_3_03` stays `#[ignore]`d `media_acceptance_integration.rs::ac_3_03_uploading_a_multi_page_pdf_creates_one_document_page_item_per_page` needs a working `pdftoppm` to actually split a real PDF. **This build host has no `poppler-utils` installed** (confirmed: `pdftoppm` not on `PATH`, no sudo to install it), so I can't verify the real-conversion path end to end here, and I did not touch that test — it isn't mine to un-ignore blind. `pdf.rs`'s own `renders_a_real_two_page_pdf_with_default_options` is `#[ignore]`d for the identical reason and was left that way when GRI-1868 landed. Everything that doesn't need a real `pdftoppm` passes: `cargo test -p server` (all gates via `scripts/local-gates.sh`), including `ac_3_06` (corrupt PDF → clean 4xx, no items) and the full `pdf.rs` unit suite against a fake converter script. Flagging to the CTO/System Administrator separately: the build host and (likely) the CI runner need `poppler-utils`, the same package I added to the runtime image, before `ac_3_03` can be un-ignored for real. ## How verified ``` SIGNAGE_TEST_DATABASE_URL=postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable \ ./scripts/local-gates.sh --rust-only # all gates pass ./scripts/local-gates.sh --frontend-only # all gates pass (untouched by this change) ```
GRI-1877: wire PDF upload to the page converter (signage #15b)
Some checks failed
CI / the pre-push hook (pull_request) Successful in 8s
CI / cargo fmt (pull_request) Successful in 8s
CI / cargo deny (pull_request) Successful in 44s
CI / cargo deny advisories (pull_request) Failing after 45s
CI / repository boundary (pull_request) Successful in 5s
CI / cargo clippy (pull_request) Successful in 10m17s
CI / cargo test (pull_request) Successful in 11m3s
CI / frontend-web (pull_request) Successful in 9m43s
CI / CI (pull_request) Successful in 3s
CI / Notify gate failed (pull_request) Has been skipped
dfd75a4e5a
vivy merged commit 9141699c2a into dev 2026-11-10 05:37:57 +00:00
vivy deleted branch feature/GRI-1877-pdf-upload-wiring 2026-11-10 05:37:57 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Grimoirix/grimoire-of-digital-signage!106
No description provided.