Catch generic exception when export to pdf#8704
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
Updates the server-side PDF export flow to fall back to WebPDFExporter when standard nbconvert.PDFExporter fails due to non-OSError conversion issues (e.g., missing Pandoc), and adds a regression test for that fallback.
Changes:
- Broaden standard PDF export failure handling from
OSErrortoExceptionto trigger webpdf fallback for more nbconvert conversion errors. - Add a test ensuring
PandocMissingtriggers fallback toWebPDFExporter.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
marimo/_server/export/exporter.py |
Catch generic exceptions during standard PDF export and warn + fall back to webpdf. |
tests/_server/export/test_exporter.py |
Add regression test for fallback behavior when PandocMissing is raised. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Improves Marimo’s PDF export reliability by expanding failure handling for “standard” nbconvert PDF generation (pandoc/TeX) and validating fallback to WebPDF.
Changes:
- Catch additional nbconvert conversion exceptions (including pandoc-missing scenarios) and fall back to WebPDF.
- Add test coverage for fallback behavior on conversion and unexpected errors.
- Update PDF export tests’ dependency skip conditions (now including playwright).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| marimo/_server/export/exporter.py | Expands exception handling in export_as_pdf to fall back to WebPDF when standard PDF conversion fails. |
| tests/_server/export/test_exporter.py | Adjusts skip conditions and adds new tests covering fallback behavior for additional exception types. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| # Try standard PDF export first (requires pandoc + TeX) | ||
| # and fall back to webpdf if it fails | ||
| from nbconvert.utils.exceptions import ( # type: ignore[import-not-found] |
There was a problem hiding this comment.
we should probably add nbconvert to our test-optional group
There was a problem hiding this comment.
sounds good, ill add in a followup
📝 Summary
Relates to #8700.
We previously only checked for OSError. It seems that this isn't sufficient to capture missing Pandoc. So instead, we catch a generic exception. Standard PDF tends to be quite strict anyway compared to WebPDF, so this is a good fallback
🔍 Description of Changes
📋 Checklist