# Case study: a WeasyPrint crash that shipped in four releases

> For nine months and four releases, WeasyPrint crashed on documents with positioned content in a running header or footer. We replayed the commit that caused it with VisualCI and 17 realistic business documents, and the build flagged it on that commit. WeasyPrint's own sample documents never showed it.

Source: https://visualci.com/blog/weasyprint-case-study/

2026-12-04, Nathan Broadbent

[WeasyPrint](https://weasyprint.org) turns HTML and CSS into PDFs. It's one of the best open source tools for the job, and a lot of Python apps use it for invoices, reports and tickets. We picked it for our first open source case study because PDFs are what VisualCI does best, and because WeasyPrint's CI already does half the work. On every push and pull request it renders eight sample documents (a book in two styles, an invoice, a letter, a poster, a flyer, a report and a ticket) and keeps them as a build artifact for a day. Nothing compares them with the previous version.

So we forked it, added VisualCI, and asked one question: would VisualCI have caught a regression that actually shipped, before it merged?

## The bug

On 26 November 2025, commit [f3d5cba](https://github.com/Kozea/WeasyPrint/commit/f3d5cba09774ea242c5e45c190e5feeb8e7cb207) ("Abort whole grid rendering if no child fits on the page") changed how WeasyPrint lays out CSS grids. It shipped in v67.0 on 2 December 2025.

From then on, a document with absolutely positioned content inside a running header or footer (the `position: running()` elements that print in the page margins) could crash with `AttributeError: 'NoneType' object has no attribute 'translate'`. In v69.0 the same documents crashed somewhere else, with an `IndexError` in `add_broken_out_of_flow`, which a user reported in July 2026 ([#2857](https://github.com/Kozea/WeasyPrint/issues/2857)). A crash that needs one particular combination of CSS is hard to pin down from a report.

It was fixed on 9 August 2026 by [eb45d5f](https://github.com/Kozea/WeasyPrint/commit/eb45d5f7d2cb6decdc24c034fb78b2bfa195eff7) ("Transform running elements into relatively-positioned boxes"), released in v70.0 on 8 September 2026. In all, four releases (67.0, 68.0, 68.1 and 69.0) and about nine months.

## What would have caught it

Not WeasyPrint's samples. We rendered all eight with every release from v66.0 to v70.0. None crashed and none showed the bug, because none of them puts positioned content in a running header.

Real business documents do. DocSpring's template library has 17 page designs: an invoice, a certificate, a badge, a receipt, a packing slip, a ticket, a quote, a report, a shipping label, a membership card, a payslip, a transcript, a letter, a timesheet, a gift certificate, an application form and a purchase order. They're laid out with CSS grid, with running headers and footers and "Page 1 of 3" counters, the way people build documents for print. We exported each as standalone HTML with its fonts and sample data, and rendered each twice: with short data, and with long data that runs over several pages. That's 34 documents.

| WeasyPrint | Samples (8) | DocSpring designs (34) |
|---|---|---|
| 66.0 | all render | all render |
| 67.0 | all render | **14 crash** |
| 68.0 | all render | **crash** (invoice checked) |
| 68.1 | all render | **14 crash** |
| 69.0 | all render | **14 crash** |
| 70.0 | all render | all render |

The 14 are the seven designs with a running header or footer (invoice, quote, payslip, transcript, letter, application and purchase order), each with both data sets.

## The replay

Our fork, [visualci-com/WeasyPrint](https://github.com/visualci-com/WeasyPrint), has a GitHub Actions job that installs WeasyPrint from the commit, renders the 8 samples and the 34 designs, and sends the PDFs to VisualCI. We pushed the commit just before f3d5cba as the baseline, then opened a pull request with f3d5cba on top.

VisualCI's build for that pull request, [build #6](https://app.visualci.com/visualci-com/weasyprint/builds/6), compared it with the baseline:

- **14 PDFs removed**: the seven header-and-footer designs, with both data sets.
- **14 error snapshots added**, each naming the document and the `AttributeError`.
- **28 unchanged**, including all eight of WeasyPrint's samples.

The pull request's VisualCI check stayed pending until someone reviewed the build, and the review rejected it, with the reason on each snapshot. Upstream, that's the commit that merged and went into a release.

## The other half: changes you meant to make

Most rendering changes in a layout engine are on purpose, and the reviewer still needs to see them. A small fix can reach a long way.

On 20 July 2026, [148bc04](https://github.com/Kozea/WeasyPrint/commit/148bc049) ("Fix break point value used to break lines") fixed soft hyphens that went missing at some font sizes. It deletes two lines in `text/line_break.py`, and it shipped in v70.0. We replayed it the same way, as a pull request in the fork on top of its parent.

VisualCI's build for it, [build #9](https://app.visualci.com/visualci-com/weasyprint/builds/9), changed one of the 42 documents: the classical-style book. With the new line breaks, it reflows from 34 pages to 32. The build lists 26 changed pages and 224 lines that moved from one page to another, each with its text, so the reviewer sees everything a two-line fix touched. We approved it, because it's the change the commit meant to make. The other 41 were unchanged. (At this July commit the 14 header-and-footer documents still crash, so they were error snapshots on both sides.)

![Page 23 of the classical-style book before and after 148bc04, and the difference in red](https://visualci.com/blog/weasyprint-case-study/linebreak-p23.png)

The release replay found two more intended changes: v67.0 rebalanced the two-column text in the report sample ("Respect top margins and avoid overlapping footnotes for columns"), and v69.0 drew the book's SVG title logo differently ("Apply presentational hints to svg tags").

## Try it on your documents

If your project renders PDFs, it's one CI step: render your documents to a folder and upload it. See [PDFs](https://visualci.com/docs/pdfs.md) and [GitHub Actions](https://visualci.com/docs/ci/github-actions.md). The 17 DocSpring designs used here are free to use under the MIT licence: get them from [DocSpring/docspring-html-designs](https://github.com/DocSpring/docspring-html-designs), or in our fork at [visualci/docspring-designs](https://github.com/visualci-com/WeasyPrint/tree/visualci-setup/visualci/docspring-designs).

<!-- Sources: fork https://github.com/visualci-com/WeasyPrint (PR #1, branches replay/f3d5cba-base and replay/f3d5cba;
     PR #2 for 148bc04); VisualCI builds #3 (baseline) and #6, #8 (baseline) and #9; release dates from
     https://github.com/Kozea/WeasyPrint/releases; bisect: git bisect run over upstream commits rendering 01-invoice. -->
