Skip to content
This repository was archived by the owner on May 13, 2026. It is now read-only.

fix(storage): stop persisting CloudSyncConfig secrets to disk - #603

Merged
shiba4life merged 1 commit into
mainlinefrom
fix/cloud-sync-config-skip-secrets-on-serialize
Apr 23, 2026
Merged

fix(storage): stop persisting CloudSyncConfig secrets to disk#603
shiba4life merged 1 commit into
mainlinefrom
fix/cloud-sync-config-skip-secrets-on-serialize

Conversation

@shiba4life

Copy link
Copy Markdown
Collaborator

Summary

`CloudSyncConfig` was serializing `api_key`, `session_token`, and `user_hash` into `node_config.json` alongside `api_url`. Those are per-device secrets that belong in the host application's credential store (e.g. fold_db_node's `credentials.json` / `credentials.enc`) — not in plaintext JSON that may be backed up, shared, or checked into a mis-gitignored directory.

Mark those three fields `#[serde(default, skip_serializing)]`:

  • new saves write only `api_url` inside `cloud_sync`
  • old files that already contain these fields still deserialize cleanly (the next save strips them)
  • the runtime still holds the fields in-memory, hydrated by the host app (e.g. `FoldNode::new` loading from credentials)

Finding #3 of the cloud-sync-activation review.

Test plan

  • `cargo test --lib storage::config` — all 9 tests pass (6 existing + 3 new)
  • `cargo clippy --workspace --all-targets -- -D warnings` clean
  • CI green
  • Cascade: fold_db_node Cargo.lock bump picks up the change; existing sync-activation tests must still pass

New tests

  • `serialize_omits_per_device_secrets` — proves api_key/session_token/user_hash don't appear in JSON output
  • `deserialize_tolerates_legacy_files_with_secrets` — proves old files still load
  • `deserialize_new_file_without_secrets_defaults_fields` — proves new files default the fields cleanly

🤖 Generated with Claude Code

`CloudSyncConfig` was serializing `api_key`, `session_token`, and
`user_hash` into `node_config.json` alongside `api_url`. These are
per-device secrets that belong in the host application's credential
store (e.g. fold_db_node's `credentials.json` / `credentials.enc`) —
not in a plaintext JSON that may be backed up, shared, or checked
into a mis-gitignored directory.

Mark those three fields `#[serde(default, skip_serializing)]` so:
- new saves write only `api_url` inside `cloud_sync`
- old files that already contain these fields still deserialize cleanly
  (the next save strips them)
- the runtime still holds the fields in-memory, populated via the host
  app's hydration path (e.g. `FoldNode::new` loading from credentials)

Tests added:
- `serialize_omits_per_device_secrets`
- `deserialize_tolerates_legacy_files_with_secrets`
- `deserialize_new_file_without_secrets_defaults_fields`

Review tracked at gbrain `projects/cloud-sync-activation-review`
(finding #3).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@shiba4life
shiba4life enabled auto-merge April 23, 2026 19:14
@shiba4life
shiba4life added this pull request to the merge queue Apr 23, 2026
Merged via the queue into mainline with commit 80974a7 Apr 23, 2026
10 checks passed
@shiba4life
shiba4life deleted the fix/cloud-sync-config-skip-secrets-on-serialize branch April 23, 2026 19:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant