Skip to content

fix(engine): keep saved connections a newer RustGIS wrote instead of dropping them - #1945

Merged
Mavrick-F merged 6 commits into
opengeos:mainfrom
Mavrick-F:fix/settings-newer-versions
Nov 14, 2026
Merged

Mavrick-F merged 6 commits into
opengeos:mainfrom
Mavrick-F:fix/settings-newer-versions

Conversation

@Mavrick-F

@Mavrick-F Mavrick-F commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Summary

An older RustGIS no longer drops saved connections it can't read when it saves the connections preference again. Before, Connections::from_json ignored the stored version, skipped rows it couldn't read, and lost fields it didn't know (the login fields of #1223 already, for a 0.5 client). Any later edit, or a login that records a remembered password, rewrote the list without them.

 Connections::from_json(text)
-  version ignored; unreadable rows skipped; unknown fields dropped
+  missing / empty            -> no connections, as before
+  version > 1, or unreadable -> no connection used, new connections refused,
+                                to_json() gives back the text byte for byte
+  version 0..=1              -> rows it can't read and fields/keys it doesn't
+                                know are kept and written back unchanged;
+                                a new connection never takes a kept row's id
 Session::load_connections(text)   (desktop, web, CLI/Python saved secrets)
+  one notice per kind, with a count (Connections::unread)
  • Kept rows go after the connections it reads. Unknown fields stay with their connection through an edit and are removed with it.
  • Secrets: data this version can't read that holds a password, key or token is dropped, with a notice, and not kept. A preference written by a newer version is refused and kept byte for byte, so this only touches unreadable rows within the version this RustGIS reads. The documented promise is that these lists hold no secrets, and a future RustGIS that stored secrets there would have to raise the version, so it can't happen silently. Within the version it reads, this RustGIS knows the schema and that promise, so it can tell a secret and drop it. A newer version's text, or text it can't parse, it can't interpret: the same field name may mean something else there, and content from a newer version is kept unchanged, never rewritten. The file isn't rewritten at all in that case (adding a connection is refused), so nothing is re-persisted.
  • There is no in-app reset for a preference kept whole (from a newer RustGIS, or unreadable): hand-editing or removing the connections key is the deliberate trade for a file that may come from a newer RustGIS, and the notice says what to do.
  • The writer still writes version 1. The file layout and commands are unchanged.

Testing

  • connections::tests::connections_keep_rows_and_fields_this_version_cannot_read: an unknown kind, a null row, an unknown field and an unknown top-level key survive an add and a rename. The new id skips the kept row's c7. Removing a connection removes its unknown fields.
  • connections::tests::connections_from_a_newer_version_or_unreadable_are_kept_whole: version 2, a non-object, a non-integer version and a non-array list are each reported once, refuse adding with that reason, and come back byte for byte. Clean input gives no notice.
  • smoke::connections_from_a_newer_version_survive_other_changes: through the app's real preference load and save, recording a recent source, favouriting a source and connection.new leave a version-2 preference byte for byte. With a version-1 preference, the unknown row and field survive the add.
  • Locally: cargo fmt --check, cargo test -p rustgis-engine --lib connection, the smoke tests above, cargo clippy -p rustgis-engine -p rustgis-ui-egui --all-targets -D warnings, cargo check --target wasm32-unknown-unknown for both crates. The full CI (fork run) passed on this head.

Merge danger: a two-way door. The blast radius is saved connections: a preference that was silently emptied before is now kept and not used, with a notice.

UI evidence

No visible UI change.

Related issue

Part of #1405 item 3 (connections). Saved sources, plugin state and the sign-in store follow in a separate PR.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Saved connection preferences with unsupported versions or malformed content are preserved instead of being overwritten by unrelated preference updates.
    • Unrecognized connection details are retained when preferences are saved, and unreadable connection entries are reported.
    • Adding connections is blocked when saved preferences cannot be safely read. Removing a connection also removes its associated unrecognized details.
  • Compatibility
    • When no saved connection preference is available, connections can still be imported from legacy source and S3 preferences.

Loading
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.

1 participant