Wire imageFetcher through CLI docs export pipeline#185
Conversation
`wafflebase docs export <id> <file>` previously called `exportPdf` and `exportDocx` with no `imageFetcher`, so any document containing even one image inline rejected the export with: imageFetcher required: document contains 1 image inline(s); first: https://api.wafflebase.io/images/<uuid>.png That guard lives in `pdf-image-painter.ts` (and a sibling check in `docx-exporter.ts`) and is intentional — silently dropping image content would change the visible output without warning. The CLI just never built a fetcher. Add `createImageFetcher({ serverBase })` that mirrors the frontend's `docsImageFetcher`: absolute URLs (`http(s):`, `data:`, `blob:`, `file:`) pass through untouched, and server-relative paths (`/images/<id>`) resolve against the CLI's configured server. The backend `GET /images/:id` route is publicly readable so no auth header is needed; the fetcher returns a `Blob` the exporter embeds directly. Plumb the fetcher into `CliPdfExportOptions.imageFetcher`, `CliDocxExportOptions.imageFetcher` (already supported), and the `docs export` action so both PDF and DOCX paths get one for free. Tests: - New `image-fetcher.test.ts` covers URL resolution rules and the fetcher's success/error mapping with an injected fetch stub. - `docs-export.test.ts` adds a regression test that reproduces the reported error message verbatim, plus an embed test that exercises the full PDF pipeline with a 1×1 PNG stub fetcher. The DOCX symmetric regression is deliberately not duplicated here because a failing `DocxExporter.export` invocation perturbs JSZip's Blob support state in pure-Node tests; that path is already covered in the docs package's jsdom-env suite.
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Verification: verify:selfResult: ✅ PASS in 137.8s
Verification: verify:integrationResult: ✅ PASS |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Adds @wafflebase/slides as a third surface alongside Sheets and Docs, plus 53-shape library (Phase 1+2), adjustment handles for 9 pilot shapes (P3-A.1), live snap guides, align/distribute toolbar, themed authoring, and layout-change UI. Also ships Sheets cell comments (Phase B), docs peer-avatar caret jump, yorkie-js-sdk 0.7.8 upgrade, and CLI/REST API improvements (docs export imageFetcher, expired session refresh, REST docs split). Minor bump because slides is a new top-level package. Highlights: #184 #185 #186 #187 #188 #189 #190 #191 #192 #197 #198 #201 #202 #203 #204 #205 #206 #207 #209 #210
Summary
wafflebase docs export <id> <file>failed for any document with an image inline because the CLI never built animageFetcherto pass toexportPdf/exportDocx. The exporters intentionally throwimageFetcher required: document contains N image inline(s); first: <url>rather than silently dropping image content.createImageFetcher({ serverBase })(parallel to the frontend'sdocsImageFetcher): absolute URLs pass through, relative/images/<id>paths resolve against the configured server, publicGET /images/:idso no auth header is needed.CliPdfExportOptions.imageFetcherand thedocs exportaction so both PDF and DOCX paths get one for free.Test plan
pnpm verify:fast(cli + docs + sheets — 2153 tests, all green)image-fetcher.test.tscovers URL resolution rules and fetch success/404 mapping with an injected fetch stub.docs-export.test.tsregression test reproduces the original error message verbatim against a doc with anhttps://api.wafflebase.io/images/<uuid>.pnginline.docs-export.test.tsembed test exercises the fullexportPdfpipeline with a 1×1 PNG stub fetcher and confirms the call resolves to a valid PDF (%PDF-header, fetcher invoked once with the absolute URL).wafflebase docs export <id> out.pdfagainst a workspace doc that contains one or more inline images.🤖 Generated with Claude Code