Pinning Python dependencies: the package you never installed
At 21:39 UTC on a Saturday in October, preshed 3.0.14 appeared on PyPI. It is a small Cython hash-table library that spaCy depends on, and nobody on the project had ever installed it on purpose. By Sunday afternoon CI was red on every pull request that ran, the logs held the same error 1,448 times, and one staging service could no longer process a single piece of text.
Nothing in the repository had changed. That is the part worth understanding before it happens to you.
How it failed
The error was OverflowError: Python int too large to convert to C ssize_t, raised inside spaCy’s tokenizer. spaCy sits under Presidio, which masks personal data before any text leaves the system for an external model. Masking is in front of every model call, so every agent step failed – and in the longest shard the failures piled up until the job hit its 45-minute timeout.
The timeline, all on 25 October, in UTC:
- 12:37 and 13:26 – CI fails on a pull request from another developer’s branch.
- 13:46 – CI fails on the integration branch’s release PR. 1,448 identical masking errors.
- 14:34 – an API service on staging is rebuilt from the same branch and picks up 3.0.14. spaCy in that container now fails on any text.
- around 18:00 – diagnosis.
- 18:14 – the pin is committed; CI goes green on all four shards and coverage, and the staging worker is rebuilt on 3.0.13.
What your pins actually pin
The project declared its dependencies in pyproject.toml, some pinned exactly (presidio-analyzer==2.2.364, litellm==1.105.0), others as ranges, and the image ran pip install .. There was no lock file. Whatever the direct pins said, everything beneath them was resolved again at build time, against PyPI as it was that minute.
So the version of the system you run is set by when its image was built, not by what is in the repository. The staging worker – the service the agents run in – had been built earlier and still held 3.0.13, which is why staging kept answering. The API service rebuilt at 14:34 didn’t.
There is a twist I didn’t chase. The worker had also been rebuilt after the release and still had the old version. My best guess is Docker’s layer cache: pyproject.toml hadn’t changed, so the dependency layer was reused. It is a guess, and it is the same problem in the other direction. Caching makes builds reproducible by accident, until the cache is evicted and they aren’t.
Bisect packages, not commits
The reflex on red CI is git bisect. Here it would have found nothing, because the code was constant and the behaviour wasn’t. When that happens the variable is the environment, and that is what you bisect.
I didn’t rebuild environments to do it. The working environment with the old versions stayed as it was, and each candidate was installed into its own directory and put first on the path:
pip install --no-deps --target /tmp/overlay "preshed==3.0.14"
PYTHONPATH=/tmp/overlay python -m pytest -q -k masking
The candidates were the packages in spaCy’s chain with a release in the window: preshed, cymem, murmurhash, srsly. Each took a few minutes. Only preshed 3.0.14 failed; its predecessor and the new versions of the others passed.
The hotfix, and why it stayed a hotfix
The fix was one line in pyproject.toml, with a comment that says why it is there:
# A dependency of spaCy, held here: preshed 3.0.14 (24.10.2026) breaks the pipeline the
# masking reads with an OverflowError, so every call of a model fails; 3.0.13 works.
"preshed==3.0.13",
The comment matters as much as the pin. A bare transitive package in a list of direct dependencies looks like a mistake, and the next person to tidy the file removes it.
The real fix is a lock file – uv lock or pip-tools, the tool matters less than the habit – with an image that installs from it. I didn’t add one, and that was a deliberate call. Ranges without a lock file were the backend team’s established practice, and switching to a lock file changes how everyone on the team upgrades. That is a decision for the team, not something to slip into a Sunday hotfix. The pin fixed CI that day; the lock file is the team’s call.
The cost is plain. One package is held, the next one can break the same way, and any service built from a branch without the pin stays broken until that branch is updated.
Fail-closed has a consequence
Underneath the incident is a design decision I would make again. Masking is fail-closed: if it can’t run, the text doesn’t go to the model. The alternative keeps the product up and sends client data to a third party unmasked.
But fail-closed moves the masking layer’s entire dependency tree onto the critical path of every model call. A library you think of as a privacy detail becomes a single point of failure for the product, and its transitive dependencies deserve the same care as your web framework. Two things follow:
- Lock the privacy layer first. If a full lock file is a team decision, a constraints file for the spaCy chain is a smaller one.
- Fail at startup, not on the first request. A smoke test that runs masking on a fixed string when a service starts turns 1,448 failed calls into one container that refuses to come up – which a deploy notices before a user does.
What I would add
A scheduled CI run, weekly, that builds on fresh dependencies with no cache. Its only job is to tell you that the world moved under you – on a Monday morning, from a job you expect to be red sometimes, rather than on a Sunday from a pull request that had nothing to do with it.
LLM systems tend to pull in heavy NLP and ML libraries with deep, fast-moving dependency trees. If your model calls depend on one of them, your uptime depends on packages you have never heard of. The same habit – check what you don’t control – runs through testing LLM integrations, and the project is described in the AI-layer case.