fix(pdf-vision): render PDFs with poppler-utils + surface a concrete admin failure reason
Summary
The AI status page's "PDF vision/native path" check fails on OpenAI-protocol providers (OpenAI, OpenAI-compatible endpoints, local Ollama, etc.) with a generic request_failed code, even on stock containers.
Root cause: Provider::Openai::PdfProcessor#convert_pdf_to_images shells out to pdftoppm from poppler-utils to render each page as PNG before sending it upstream as an image part. The checked-in Dockerfile (and therefore ghcr.io/we-promise/sure:stable) does not install poppler-utils. The call's return value was never checked, so the subsequent Dir.glob came back empty, the probe raised, and the admin page only showed the ambiguous request_failed code — no hint that a system binary was missing.
Changes
Dockerfile— addpoppler-utilsto the productionapt-get installline sopdftoppmis present. This is the actual fix for the failing check.app/models/provider.rb— extendProvider::Errorwith an optionalfailure_code:keyword (backwards compatible; defaults tonil).app/models/provider/openai/pdf_processor.rb— capturesystem("pdftoppm", …)'s return value. When it isfalseand acommand -v pdftoppmlookup confirms the binary is genuinely absent, raiseProvider::Openai::Errorwithfailure_code: :render_missing_binary. Any other non-zero exit (corrupt input, OOM, disk-full) falls through to the existingrescue => ebehaviour of logging and returning[], so we don't regress today's "bad PDF" path into a new hard error.app/models/ai_health/probe.rb—failure_code(error)now falls through to the default:timeout/:request_failedlogic when the error'sfailure_codeisnil(previously it would returnnilstraight off the first branch).config/locales/views/admin/system_health/en.yml— add therender_missing_binaryadmin-facing message: "The pdftoppm renderer (poppler-utils) is not available in this container".test/models/provider/openai/pdf_processor_test.rb— add two regression tests:- missing binary →
Provider::Openai::Errorwithfailure_code == :render_missing_binaryand a message mentioningpoppler-utils - binary present but
systemreturnsfalsefor another reason → still returns[](preserves existing degradation)
- missing binary →
Out of scope / not changed
Provider::Anthropic::PdfProcessoralready uploads the raw PDF as a nativedocumentsource and never callspdftoppm, so the Anthropic path is unaffected.- The
pdf-readergem (pure-Ruby parser) covers the text-extraction path, which is unaffected. - Adding
poppler-utilstoGemfile.lockor any other packaging artifact is not required — only the Debian base image needs it.
Verification
Static analysis of the full diff + manual trace of the two test paths. I was unable to run the project's RSpec suite from this environment (no local Ruby toolchain; Docker Hub blocked at the registry layer). The binary_missing? helper uses a command -v probe so it correctly distinguishes binary absent (the new coded error) from pdftoppm failing at runtime (preserved [] fallback).
Notes for reviewers
Provider::Error#initializekeeps its existing positional/keyword signature and only adds a new optional kwarg, so existing callers (including the manyProvider::Openai::Error.new(...)sites underapp/models/provider/openai/**) are unaffected.- The new locale key is the single source of truth for the UI string; no other locale files were touched in this repo.
- I confirmed upstream has no open issue or PR already touching this — the related search (
pdftoppm,poppler,#3191) returned zero open issues and no merged PR for this specific gap.
Summary by CodeRabbit
-
Bug Fixes
- Improved PDF processing when rendering tools are unavailable or reject a document.
- Added clearer health reporting and diagnostic codes for PDF rendering issues.
- Preserved graceful handling of invalid PDFs and improved consistency in provider error reporting.
-
Chores
- Added required PDF rendering support for image-based document processing.
- Expanded coverage for missing tools, failed conversions, and provider error details.