fix(audit): gracefully handle malformed response#32234
Conversation
deno audit fails to deserialize npm registry response|
@copilot try again |
Co-authored-by: bartlomieju <13602871+bartlomieju@users.noreply.github.com>
Done! The fix is implemented in commit |
|
It's not - looks like an actual npm problem. |
|
I've found this issue: #31671 , which was fixed in v2.6.2. I've tried upgrading to that version and other 2.6 versions, and it did not fix the issue. Currently, the behavior works again (tested with 2.6.10), probably due to changes in the npm registry response. |
…-4fa2-9b85-583e559c03fc
dsherret
left a comment
There was a problem hiding this comment.
I feel like an integration test here is a bit much (slows down ci over time). Maybe let’s convert this to a quick deserialization unit test?
|
@copilot see my last comment. |
…tion Co-authored-by: dsherret <1609021+dsherret@users.noreply.github.com>
Replaced the integration test with a unit test in commit |
|
@copilot make sure to run |
Ran |
|
@copilot you must run |
Co-authored-by: bartlomieju <13602871+bartlomieju@users.noreply.github.com>
Ran the formatter with the dprint config options in commit Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Fixes an issue where
deno auditfails to deserialize npm registry responses when theactionsfield is missing.Changes Made
#[serde(default)]attribute to theactionsfield inAuditResponsestruct incli/tools/pm/audit.rs- this makes the field default to an emptyVecwhen missing from the JSON responseactionsfield is missingFix Details
The issue was that the npm registry audit API response sometimes doesn't include the
actionsfield. The Deno audit code was expecting this field to always be present, causing deserialization to fail with:missing field 'actions' at line 1 column 33The fix adds
#[serde(default)]to theactionsfield, which makes it default to an empty vector when the field is not present in the JSON response. This is the standard serde pattern for optional fields that should have a sensible default value.Original prompt
deno auditfails to deserialize npm registry response #32233💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.