Fix deserialization error when Homebrew returns null installation timestamps#20
Conversation
Co-authored-by: cosmincatalin <525590+cosmincatalin@users.noreply.github.com>
cosmincatalin
left a comment
There was a problem hiding this comment.
You need to also bump the version
|
The version of the package needs to be bumped up at patch version. |
cosmincatalin
left a comment
There was a problem hiding this comment.
The version of the app needs to be bumped with a patch increment.
After this, cargo update needs to be run.
|
@copilot , fix the conflicts and do the work. |
Co-authored-by: cosmincatalin <525590+cosmincatalin@users.noreply.github.com>
Fixed merge conflicts and bumped version to 0.1.4 in commit 70f32cb. The branch now includes both the null time field fix and the null homepage fix from main. All 12 tests pass.
Fixed merge conflicts and bumped version to 0.1.4 in commit 1f94ca8. The branch now includes both the null time field fix and the null homepage fix from main. All 12 tests pass. |
Problem
The application was failing to load packages from Homebrew with the following error:
This resulted in only a "homebrew-error" placeholder being displayed instead of the user's installed packages:
Root Cause
The
BrewInstalledstruct defined thetimefield as a non-nullableu64, but Homebrew's JSON API can returnnullfor installation timestamps in certain scenarios:When
serde_jsonattempted to deserialize a JSON response with a nulltimefield, it raised a deserialization error that prevented all packages from loading.Solution
Changed the
timefield fromu64toOption<u64>to handle both valid timestamps and null values gracefully:Packages with null timestamps are treated as having timestamp
0(Unix epoch) for sorting and comparison purposes, ensuring consistent behaviour across the application.Changes
time: u64→time: Option<u64>and added test for null timestamp deserialization; merged with null homepage handling from mainOption<u64>when finding the latest installation; includes null homepage handling0.1.3to0.1.4Testing
test_deserialize_formula_with_null_timeto verify null timestamps are handled correctlyImpact
Before: Application crashed when encountering packages with null timestamps
After: All packages load successfully, including those with null timestamps and null homepages
This fix ensures brew-explorer works reliably for all Homebrew installations, regardless of whether packages have timestamp or homepage information available.
Fixes #17
Original prompt
Fixes #17
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.