Security Bug Report

uv audit failed every CI build with "error decoding response body": one malformed OSV record

One morning our audit step turned every Python pipeline red without a single new dependency. The cause was an advisory record with an empty range event that uv could not parse. How we proved it was upstream data and redesigned the gate so a broken feed fails loudly without freezing the team.

Hannah Okafor Hannah Okafor @hannahokafor · November 17, 2026 · 7 min read · 195 Views
701-uv-audit-osv-error-decoding-response-body

After the March 2026 litellm incident we added a vulnerability audit to every Python pipeline. uv had gained an audit command behind a preview flag, so the step was one line:

uv audit --preview-features audit

It ran for weeks without trouble. On 2026-05-20 it started failing in every repository at once, including ones whose lockfiles had not changed in a month. The error chain ended in two lines:

error decoding response body
expected value at line 1 column 4817

The column number differed between repositories. Re-running the job gave the same error. Our on-call first suspected a network problem, then a uv regression.

Reproducing it

On a laptop with uv 0.11.15 the command failed the same way against one of our repositories. We pinned the previous uv release to test the regression theory:

uvx --from 'uv==0.11.14' uv audit --preview-features audit

It failed too, which pointed away from a uv code change and toward the data uv was reading.

What we ruled out

  • Our lockfiles. Repositories with no changes for weeks failed the same morning.

  • A proxy or TLS problem. The error was a parse failure on a response body that had arrived, not a connection error.

  • A uv regression. The previous release failed identically.

Root cause

The upstream issue confirmed it within hours. An advisory record, PYSEC-2026-89, had an empty object {} inside affected.ranges.events. The OSV schema requires each event to have one of introduced, fixed, last_affected or limit, so the record was invalid. uv parses the OSV response strictly and refused the whole response. A similar malformed record existed for a PyJWT advisory. Any project whose dependency set caused uv to request those records failed.

What is happening under the hood

uv audit takes the resolved packages from the lockfile and asks the OSV database which advisories affect those versions. OSV aggregates data from sources such as the Python Packaging Advisory Database. Each advisory lists affected ranges as a sequence of events:

{
  "affected": [{
    "package": {"ecosystem": "PyPI", "name": "example-lib"},
    "ranges": [{
      "type": "ECOSYSTEM",
      "events": [{"introduced": "0"}, {"fixed": "2.4.1"}]
    }]
  }]
}

The broken record had an event like {} in that list. A strict deserializer cannot map an empty object to any event variant, so it errors out. The column in our error message was simply where that object sat in each response, which is why it varied by repository.

The maintainers labelled the issue as external. The fix was a backfill of the malformed records on the advisory database side. uv improved the error message, so a future failure names the bad record, but kept strict parsing. That is a reasonable choice: silently skipping records you cannot parse could hide a real vulnerability.

Environment

Component

Version / value

uv

0.11.15 (0.11.14 also failed)

Command

uv audit --preview-features audit

Data source

OSV, records from the Python advisory database

Bad record

PYSEC-2026-89, empty {} in affected.ranges.events

CI

GitHub Actions, audit as a required check

Who is affected

Anyone using a strict OSV consumer while a malformed record is live. The same class of failure can hit any scanner that reads a shared advisory feed. It is not specific to uv.

The fix

1. Confirm the failure is in the feed, not in your project. Query OSV directly for a package in your lockfile and validate what comes back:

curl -s https://api.osv.dev/v1/query \
  -d '{"package": {"ecosystem": "PyPI", "name": "pyjwt"}}' \
  | python3 -c '
import json, sys
data = json.load(sys.stdin)
for v in data.get("vulns", []):
    for a in v.get("affected", []):
        for r in a.get("ranges", []):
            for e in r.get("events", []):
                if not e:
                    print("empty event in", v["id"])
'

If this prints a record id, the feed is the problem. Check the upstream tracker before changing anything in your pipeline.

2. Do not just delete the gate. Our first instinct was continue-on-error: true. That would have turned the audit into decoration for however long the feed stayed broken. Instead we split two outcomes that look the same in a red build: "vulnerabilities found" and "the scanner could not run".

3. Fall back to a second scanner when the first cannot run. We export the lockfile and run pip-audit against it if uv audit fails for a reason other than findings:

#!/usr/bin/env bash
# audit.sh: fail on findings; on scanner failure, try a second scanner, then fail loudly
set -uo pipefail

if out=$(uv audit --preview-features audit 2>&1); then
  echo "$out"; exit 0
fi
echo "$out"

if grep -qi 'error decoding response body' <<<"$out"; then
  echo "::warning::uv audit could not read the advisory feed; falling back to pip-audit"
  uv export --format requirements-txt --no-hashes > /tmp/req.txt
  uvx pip-audit --requirement /tmp/req.txt --strict
  exit $?
fi

exit 1   # real findings or another error

pip-audit uses the PyPI vulnerability service by default, a different code path from uv's parser, so a single malformed record is unlikely to break both. If both fail, the job fails and someone looks at it.

4. Track the upstream fix. We subscribed to the uv issue and the advisory database backfill issue. When the records were corrected, uv audit worked again with no change on our side.

Alternatives and trade-offs

  • Cache the last good audit result. Allow a merge if the lockfile has not changed since the last successful audit. Safe for unchanged dependencies, useless for the pull request that adds a new one.

  • Time-boxed bypass. A label such as audit-feed-outage that lets a pull request merge for 24 hours, with an automatic follow-up audit. Needs discipline.

  • Non-blocking audit plus a nightly blocking one. Less friction, but vulnerable versions can be merged and deployed before the nightly run.

How to test the fix

  • Point the script at a fake uv that prints the decode error and exits 1, and confirm it falls back to pip-audit.

  • Add a dependency with a known advisory to a test branch and confirm the job fails on findings from either scanner.

  • Make both scanners fail (block network in the job) and confirm the job fails instead of passing.

Confirming in production

During the outage, pipelines went green through the fallback with a visible warning annotation, and one pull request was correctly blocked by pip-audit for a vulnerable version of an HTTP library. After the upstream backfill, uv audit passed again and the fallback stopped triggering. We kept it in place.

Regression guard

  • A weekly job runs audit.sh with a stubbed failing uv to prove the fallback still works.

  • The warning annotation creates a ticket automatically if it fires on more than ten pipelines in an hour, so a feed outage gets an owner.

  • We pin the uv version in CI and upgrade it deliberately, since audit is still a preview feature.

Security implications

A security gate that fails open silently is worse than no gate, because people believe it works. A gate that fails closed with no fallback gets disabled under pressure. The design above keeps the check meaningful during a feed outage and makes every bypass visible. Also note that strict parsing is a feature: a scanner that skips records it cannot read may report "no vulnerabilities" for a package that has one.

Prevention checklist

  • Distinguish "findings" from "scanner failed" in your audit step.

  • Keep a second, independent scanner as a fallback.

  • Pin scanner versions in CI, especially preview features.

  • Validate advisory data directly before blaming your own project.

  • Never use continue-on-error on a security check without an alert.

References

Add a label

#python #ci #uv #osv #vulnerability-scanning
Written by
Hannah Okafor @hannahokafor

I am a frontend engineer who has worked on dashboards, booking flows and design systems, mostly in React and TypeScript. I care about the parts of the web platform that frameworks hide: forms, cookies, rendering cost and what the browser actually does with our code. The bugs I write about usually passed every review and only appeared with production data: a map with a million points, a name with an accent in a PDF, a cookie that one subdomain never sees. Each post shows a minimal reproduction, why the browser or framework behaves that way, and a fix with a test.

Advertisement

Comments

0

No comments yet. Be the first to comment!

Sign In to post a comment.