Skip to content

feat(client): add Merged conflict resolution result that stays conditional - #582

Merged
adrianhall merged 1 commit into
CommunityToolkit:mainfrom
adrianhall:issues/579
Nov 5, 2026
Merged

adrianhall merged 1 commit into
CommunityToolkit:mainfrom
adrianhall:issues/579

Conversation

@adrianhall

Copy link
Copy Markdown
Collaborator

Summary

Fixes #579.

When an IConflictResolver returned ConflictResolutionResult.Client, the forced re-send had no If-Match header. That is correct for a plain "client wins" policy, but it is unsafe for a merge resolver. A merged entity is computed from the server row in the 409/412 response, so any write that lands before the forced PUT is silently overwritten.

Changes

  • Add ConflictResolutionResult.Merged. The re-send is conditional: it sends If-Match with the version of the server entity that the resolver received.
  • If the server responds with another 409/412, the resolver is called again with the newer server entity. After 5 attempts the operation is left in the queue as Failed.
  • If the server entity has no version, a Merged result cannot be made conditional. The operation is left as Failed rather than silently falling back to a force write.
  • Client behaviour is unchanged (a true force write), so existing users are unaffected. Its XML docs now say it is an unconditional overwrite.
  • Docs (docs/in-depth/client/index.md) describe every result value and warn that Client is not safe for merges. The custom-resolver example now returns Merged.

Tests

New tests in ConflictResolver_Tests:

  • Client still sends no If-Match.
  • Merged sends If-Match with the server version.
  • Merged re-resolves when the server changes again.
  • Merged fails after the maximum number of attempts.
  • Merged fails when the server entity has no version.

The full client test suite passes locally (1440 tests). build-library.yml and build-docs.yml pass on the fork. One earlier library run failed on an unrelated threading test, QueueHandler_WithThreads_EnqueueRange(nThreads: 8), and passed on re-run.

…ional

ConflictResolutionResult.Client force-writes with no If-Match header, which
can silently overwrite a concurrent update when the resolver merged the
entity from the server row.  Add ConflictResolutionResult.Merged, which sends
If-Match with the server entity version the resolver saw, re-resolves on a
further conflict (up to 5 attempts), and documents that Client is an
unconditional overwrite.

Fixes CommunityToolkit#579
@adrianhall
adrianhall merged commit 08c1330 into CommunityToolkit:main Nov 5, 2026
7 checks passed
@adrianhall
adrianhall deleted the issues/579 branch November 5, 2026 18:02
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.

Resolver result Client writes without If-Match, so a merge can silently lose a concurrent update

1 participant