-
Notifications
You must be signed in to change notification settings - Fork 24
fix(agent): improve productinfo.json parsing resilience #1594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Add optional Date field to ChannelData struct to handle live productinfo.json - Add forward compatibility via flattened _other HashMap for unknown fields - Add validation for empty URLs and hashes - Add detailed warning logs for parsing failures with context - Add deny_unknown_fields to ProductFile for safety - Add comprehensive tests for Date field, unknown fields, and validation
Let maintainers know that an action is required on their side
|
|
|
||
| /// Information about a product file available for download | ||
| #[derive(Debug, Clone, Deserialize, Serialize)] | ||
| #[serde(deny_unknown_fields)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Does we need to make it stricter here?
| // Allow unknown fields at channel level for forward compatibility. | ||
| // New marketing fields or metadata won't break parsing. | ||
| #[serde(flatten)] | ||
| #[serde(skip_serializing)] | ||
| pub _other: HashMap<String, serde_json::Value>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: I suppose it’s to keep information when performing round-trip encoding?
|
@copilot Reviewing this PR, here is my feedback, citing the original PR’s body. Please, think and apply the suggestions.
By default, use serde::Deserialize;
#[derive(Debug, Deserialize)]
struct MyData {
// We only know about this one field
known: i32,
}
fn main() {
// JSON has an extra field `unknown` that does not exist in `MyData`
let json = r#"{ "known": 1, "unknown": 42 }"#;
// This succeeds: by default, unknown fields are ignored.
let data: MyData = serde_json::from_str(json).unwrap();
assert_eq!(data.known, 1);
println!("{:?}", data); // MyData { known: 1 }
}I don’t think the
Logging warnings in the |
|
Superseded by #1595 |
Problem
The live productinfo.json from https://devolutions.net/productinfo.json contains a
Datefield (e.g.,"Date": "2025-11-27") in each channel object that wasn't present in the Rust struct definition. This was causing parsing failures when the agent tried to deserialize the JSON for automatic updates.Additionally, the parser had no resilience for future field additions and provided poor error diagnostics when parsing failed.
Solution
This PR improves the productinfo.json parser to be more robust and forward-compatible:
🔧 Changes Made
Added optional
Datefield toChannelDatastructForward compatibility via
#[serde(flatten)]_otherHashMapInput validation
Better error diagnostics
warn!()for each failure pointStricter ProductFile parsing
#[serde(deny_unknown_fields)]to catch typos in critical fields🧪 Testing
Added comprehensive test coverage:
🎯 Impact
Issue: Reported by tester following PR #1591