You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
LoadStateAsync with JsonFilePersistenceProvider always throws InvalidOperationException, so saved navigation can never be restored #53
NavigationState<T> (Navigation/Models/NavigationState.cs, ~line 21) has the constructor NavigationState(IEnumerable<T> items, int currentIndex), but the matching property is IReadOnlyList<T> Items. System.Text.Json requires a constructor parameter to have the same type as the property it binds to, so JsonSerializer.Deserialize<NavigationState<T>> throws InvalidOperationException.
JsonFilePersistenceProvider.LoadStateAsync (Navigation/Services/JsonFilePersistenceProvider.cs, ~lines 68-70) only catches JsonException and IOException, so the exception reaches the caller. No test performs a JSON load.
Observed:InvalidOperationException: Each parameter in the deserialization constructor on type 'ktsu.Navigation.Models.NavigationState1[...]' must bind to an object property or field on deserialization...`
Expected:true, with the history and current item restored.
With the fix below applied temporarily, the same repro loaded correctly.
Why it matters
The JSON file provider is the library's only built-in durable persistence, and the README's persistence example crashes on the load side. Saving appears to work, so the failure only shows up on the next app start.
Priority: High. JsonFilePersistenceProvider is the library's only built-in durable persistence, and its load path always throws. The README's persistence example crashes on load. Saving appears to succeed, so users only find out on the next app start.
Area / suggested assignee:NavigationState<T> deserialization constructor, and the exception handling in JsonFilePersistenceProvider.LoadStateAsync. Maintainer: @matt-edmondson.
Next steps: Add the [JsonConstructor] overload that takes IReadOnlyList<T>. Decide whether the provider should return null on unreadable data by also catching NotSupportedException / InvalidOperationException. Add a save-then-load test through JsonFilePersistenceProvider, which is currently missing.
Activity
matt-edmondson commentedon Sep 26, 2026
Triage
JsonFilePersistenceProvideris the library's only built-in durable persistence, and its load path always throws. The README's persistence example crashes on load. Saving appears to succeed, so users only find out on the next app start.NavigationState<T>deserialization constructor, and the exception handling inJsonFilePersistenceProvider.LoadStateAsync. Maintainer: @matt-edmondson.NavigationStateround-trip. That bug is hidden until this one is fixed, because a JSON load never gets far enough to restore a position. Fixing both together, with one round-trip test suite, makes sense.[JsonConstructor]overload that takesIReadOnlyList<T>. Decide whether the provider should returnnullon unreadable data by also catchingNotSupportedException/InvalidOperationException. Add a save-then-load test throughJsonFilePersistenceProvider, which is currently missing.Generated by Claude Code