Skip to content

fix(sync): propagate decode errors instead of silently reverting to defaults#1141

Merged
datlechin merged 1 commit into
mainfrom
fix/sync-decode-no-silent-fallback
May 9, 2026
Merged

fix(sync): propagate decode errors instead of silently reverting to defaults#1141
datlechin merged 1 commit into
mainfrom
fix/sync-decode-no-silent-fallback

Conversation

@datlechin

Copy link
Copy Markdown
Member

Summary

  • SyncRecordMapper.toConnection and toSSHProfile now throws instead of returning optional. Four try? decode sites for sshConfigJson, sslConfigJson, additionalFieldsJson, and jumpHostsJson propagate decode errors through a typed SyncDecodeError instead of falling back to empty defaults.
  • SyncCoordinator.applyRemoteConnection / applyRemoteSSHProfile log the failing record name + field, then skip the record. Local state stays intact, so the next push won't overwrite the cloud copy with empty defaults.

Why this matters

Cross-version schema drift caused silent data loss: device on an older app build pulls a record written by a newer build → try? decode of the SSH/SSL config blob fails on an unknown shape → fallback substitutes SSHConfiguration() / SSLConfiguration() → next push from the older device writes empty configs to CloudKit, overwriting the authoritative copy from the newer device.

This is bug B2 from the full-app audit (2 CRITICAL data-loss findings); B1 shipped as #1140.

Test plan

  • Manual: write a CloudKit record locally with a malformed sshConfigJson blob, run a pull, confirm the record is skipped (log: Skipping remote connection ...: Sync record decode failed for sshConfigJson: ...) and local connection is unchanged.
  • Manual: same for sslConfigJson, additionalFieldsJson, jumpHostsJson (SSH profile).
  • Manual: confirm a normal pull with valid records still applies them and advances state.
  • swiftlint --strict clean.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@datlechin datlechin merged commit d5e1eb4 into main May 9, 2026
2 checks passed
@datlechin datlechin deleted the fix/sync-decode-no-silent-fallback branch May 9, 2026 15:36
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