Skip to content

fix(gui-client): allow legacy settings to parse new format#9418

Merged
jamilbk merged 2 commits into
mainfrom
fix/gui-client-settings
Jun 5, 2025
Merged

fix(gui-client): allow legacy settings to parse new format#9418
jamilbk merged 2 commits into
mainfrom
fix/gui-client-settings

Conversation

@thomaseizinger

@thomaseizinger thomaseizinger commented Jun 5, 2025

Copy link
Copy Markdown
Member

As part of the introduction of General settings, we split up "Advanced settings" and also renamed one of the fields. Upon first start, the settings are migrated to the new format. What we failed to notice is that one the next subsequent start, the legacy settings struct will fail to parse the now migrated configuration and fall back to the default. This then appears as if the settings are not getting saved.

Resolves: #9417

@thomaseizinger thomaseizinger requested review from Copilot and jamilbk June 5, 2025 08:53
@vercel

vercel Bot commented Jun 5, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
firezone ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 5, 2025 3:55pm

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR ensures that after migrating settings to the new format, legacy settings structs can still parse the updated JSON, preventing silent fallbacks to defaults.

  • Added a serde(alias) on auth_base_url to accept the old "auth_url" key.
  • Introduced a test verifying that AdvancedSettingsLegacy can deserialize the new format without errors.
Comments suppressed due to low confidence (2)

rust/gui-client/src-tauri/src/settings.rs:315

  • The test only checks that parsing doesn't panic but doesn't verify that fields map correctly. Add assertions comparing fields of the deserialized AdvancedSettingsLegacy to the original AdvancedSettings::default() values to ensure the alias works as intended.
serde_json::from_str::<AdvancedSettingsLegacy>(&new_format).unwrap();

rust/gui-client/src-tauri/src/settings.rs:45

  • [nitpick] Consider adding a comment above this alias to explain that it's intended to maintain compatibility with legacy JSON field names, which helps future maintainers understand the migration rationale.
#[serde(alias = "auth_url")]

@thomaseizinger

Copy link
Copy Markdown
Member Author

Confirmed to fix the problem: #9417 (comment)

@thomaseizinger thomaseizinger enabled auto-merge June 5, 2025 11:30
@thomaseizinger thomaseizinger added this pull request to the merge queue Jun 5, 2025
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jun 5, 2025
@jamilbk

jamilbk commented Jun 5, 2025

Copy link
Copy Markdown
Member

Ah I did not test upgrades.

@jamilbk jamilbk force-pushed the fix/gui-client-settings branch from d6c68d1 to c097047 Compare June 5, 2025 15:53
@jamilbk jamilbk enabled auto-merge June 5, 2025 15:59
@jamilbk jamilbk added this pull request to the merge queue Jun 5, 2025
@thomaseizinger

Copy link
Copy Markdown
Member Author

Ah I did not test upgrades.

Upgrades aren't the issue. Reading the migrated format is because we always expected the old format on startup.

Merged via the queue into main with commit 7b0e33f Jun 5, 2025
111 checks passed
@jamilbk jamilbk deleted the fix/gui-client-settings branch June 5, 2025 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Settings lost after Firezone restart

3 participants