Repository navigation
fix(sync): write trust.json before adopting the change in memory - #331
Merged
Merged
Conversation
SaveThumbprint and RemoveThumbprint mutated _cache and then called Persist(), so a write that threw (full disk, permissions, an AV lock on Windows) left this instance trusting a certificate trust.json does not record. The divergence survives for the rest of the process and it matters: the next start reads the file back and re-prompts for a host the session had silently accepted. Build the candidate dictionary off to the side, write it, and only then adopt it -- a failed write now changes nothing at all. RemoveThumbprint additionally consumed Dictionary.Remove's return value before persisting, so after a failed write the entry was already gone from memory and a retry saw false and skipped the write entirely, leaving the thumbprint on disk forever. Removing from the candidate fixes that too. Also drop a three-line comment block above OnSnapshot in RemoteIncidentSession that was duplicated verbatim. Part of #302. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YavFrkz1GFaMNXbHQKsMyf Signed-off-by: Thomas Müller <1005065+DeepDiver1975@users.noreply.github.com>
DeepDiver1975
force-pushed
the
fix/trust-store-write-order
branch
from
September 15, 2026 20:15
e36aac8 to
37b03f5
Compare
This was referenced Sep 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two more items off the #302 checklist, both in
LageBuch.Sync.JsonTrustStore.Persist()mutated memory before the disk write.SaveThumbprintandRemoveThumbprintupdated_cacheand then wrote, so a write that threw (full disk,permissions, an AV lock on Windows) left the running app trusting a certificate
trust.jsondoesnot record. That divergence lasts for the rest of the process, and it is user-visible: the next
start reads the file back and re-prompts for a host this session had silently accepted.
The candidate dictionary is now built off to the side, written, and only adopted once the write
lands — a failed write changes nothing at all.
While confirming that, a second bug fell out:
RemoveThumbprintconsumedDictionary.Remove'sreturn value before persisting, so after a failed write the entry was already gone from memory
and a retry saw
falseand skipped the write entirely — leaving the thumbprint on disk forever.Removing from the candidate instead fixes that, and the second test covers it.
The duplicated comment block above
OnSnapshotinRemoteIncidentSession.csis gone.Both new tests were confirmed to fail against
mainand pass with the fix.Changes
JsonTrustStore: build → persist → adopt, all still under_gate;Persisttakes thedictionary to write rather than reading the field
RemoteIncidentSession: drop the verbatim-duplicated three-line commentJsonTrustStoreTests: a failedSaveThumbprintleaves memory agreeing with disk;a failed
RemoveThumbprintleaves the thumbprint trusted and a retry still does the workChecklist
git commit -s)dotnet buildanddotnet testpass locally (make ci, all eight projects)Part of #302.
🤖 Generated with Claude Code
https://claude.ai/code/session_01YavFrkz1GFaMNXbHQKsMyf