Skip to content

Skip and warn on malformed OSV records#19496

Closed
woodruffw wants to merge 3 commits into
mainfrom
ww/skip-malformed-osv
Closed

Skip and warn on malformed OSV records#19496
woodruffw wants to merge 3 commits into
mainfrom
ww/skip-malformed-osv

Conversation

@woodruffw

Copy link
Copy Markdown
Member

Summary

We now skip (and warn) if we encounter a malformed OSV record. This is (IMO) more correct that trying to suss out the intent behind a malformed record, since OSV is a strictly-defined format and the only reason we're seeing this at the moment is because OSV appears to be having a regression that their tests didn't catch.

Ref: pypa/advisory-database#284

Fixes #19492.

Test Plan

Added an integration test.

Signed-off-by: William Woodruff <william@yossarian.net>
@woodruffw woodruffw self-assigned this May 20, 2026
@woodruffw woodruffw added the preview Experimental behavior label May 20, 2026
@woodruffw woodruffw requested a review from zanieb May 20, 2026 13:46
@woodruffw woodruffw requested a review from charliermarsh May 20, 2026 13:47
Signed-off-by: William Woodruff <william@yossarian.net>
Comment thread crates/uv-audit/src/service/osv.rs Outdated
Signed-off-by: William Woodruff <william@yossarian.net>
match response.json::<Vulnerability>().await {
Ok(vuln) => Ok(Some(vuln)),
Err(err) if err.is_decode() => {
warn_user!("Skipping malformed OSV record: {id}");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't make sense for warn_user! imo — it's not an actionable warning for a user.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kind of a tough spot though.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I'm not sure if there's a better fit ATM. It's not directly actionable, but we do want users to warn us (or better yet, OSV) if this ever regresses.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we're going to get reports of this though given that message. hm.

This is in uv audit?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, in uv audit.

My 0.02c is that I'm equally fine with keeping this as a hard error (maybe with a better error message than the current JSON one) -- this is squarely a regression in OSV and I agree that users are less likely to tell us about it if we're suppressing it, even with a warning. If you're -1 on this then I'll switch to making the error message itself better instead.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I think uv audit should hard fail here if it can't perform an audit.

I think we could add an --skip-malformed-entries flag or something?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, works for me. I'll follow up with a better error PR.

I think we could add an --skip-malformed-entries flag or something?

Maybe, although my worry with a flag would be similar (users will habituate themselves into using it). Maybe that's not a realistic concern on my part.

@astral-sh-bot

astral-sh-bot Bot commented May 20, 2026

Copy link
Copy Markdown

uv test inventory changes

This PR changes the tests when compared with the latest successful main baseline.

  • Added tests: 5
  • Removed tests: 0
  • Changed suites: 2
uv-audit: +1 / -0

Added:

  • uv-audit::service::osv::tests::test_deserialize_empty_event

Removed: none

uv::it: +4 / -0

Added:

  • uv::it::audit::audit_malformed_vulnerability_record
  • uv::it::pip_exclude_newer_relative::pip_install_exclude_newer_relative
  • uv::it::pip_exclude_newer_relative::pip_install_exclude_newer_relative_config
  • uv::it::show_settings::resolve_system_configuration_can_be_disabled

Removed: none

@woodruffw woodruffw closed this May 20, 2026
@woodruffw woodruffw deleted the ww/skip-malformed-osv branch May 20, 2026 15:25
sscargal added a commit to MemMachine/MemMachine that referenced this pull request May 20, 2026
Temporarily skip the workflow when `uv audit` exits non-zero due to the
upstream OSV/uv deserialization bug (astral-sh/uv#19492). The bad OSV
record (PYSEC-2026-89 and similar) contains an empty `{}` in
`affected.ranges.events`, which uv's strict Rust deserializer rejects,
aborting the entire audit before vulnerabilities can be reported.

The workflow now:

- Captures uv audit's stderr separately and forwards it to the run log.
- Detects the specific `error decoding response body` failure mode.
- Emits a GitHub Actions ::warning:: annotation plus a Step Summary
  explaining what was skipped, why, and how to remove the shim.
- Exits successfully so unrelated PRs aren't blocked while we wait for
  the upstream fix (astral-sh/uv#19496 or equivalent).

All other uv audit error exit codes (>1) still fail loudly. Once the
`setup-uv` version is bumped past 0.11.15 to a release containing the
upstream fix, the workaround branch should be removed so future audit
regressions surface immediately.

Signed-off-by: Steve Scargall <37674041+sscargal@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

preview Experimental behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

uv audit fails with error decoding response body when OSV returns empty range events

3 participants