Skip to content

Conflict Resolution

This guide explains how to detect, manage, and resolve data conflicts in PinkCloudSync1.

Best Practices for Conflict Resolution

  1. Start with analysis — Understand conflict patterns before choosing a strategy
  2. Use automatic strategies — For non-critical data, automate resolution
  3. Review manually — For critical data, always review conflicts manually
  4. Document decisions — Keep track of resolution strategies and reasons
  5. Monitor trends — Track conflict rates to identify data quality issues

Overview

A conflict occurs when the same record has been modified in both the source and target systems. PinkCloudSync provides flexible strategies to handle these situations.

graph TD
    A[Sync Process] --> B{Conflict Detected?}
    B -->|No| C[Apply Changes]
    B -->|Yes| D{Strategy}
    D -->|Manual| E[Queue for Review]
    D -->|Source Wins| F[Use Source Data]
    D -->|Target Wins| G[Use Target Data]
    D -->|Newest Wins| H[Compare Timestamps]
    E --> I[Manual Resolution]
    F --> C
    G --> C
    H --> C
    I --> C

Understanding Conflicts

When Conflicts Occur

Conflicts happen when:

  • The same record exists in both systems with different values
  • Both versions have been modified since the last sync
  • No clear precedence can be determined automatically

Conflict Example

Source System:

1
2
3
4
5
6
{
  "id": "user_123",
  "name": "John Doe",
  "email": "john.doe@example.com",
  "updated_at": "2025-01-03T09:00:00Z"
}

Target System:

1
2
3
4
5
6
{
  "id": "user_123",
  "name": "John Smith",
  "email": "john.doe@example.com",
  "updated_at": "2025-01-03T09:30:00Z"
}

Conflict

The name field differs between systems. Which version should be kept?

Conflict Strategies

Automatic Strategies

Configure automatic conflict resolution when creating a sync session:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
curl -X POST https://api.pinkcloudsync.example/v1/sync/sessions \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "source": { /* ... */ },
    "target": { /* ... */ },
    "options": {
      "conflict_strategy": "newest_wins"
    }
  }'
1
2
3
4
5
6
7
payload = {
    "source": { /* ... */ },
    "target": { /* ... */ },
    "options": {
        "conflict_strategy": "newest_wins"
    }
}

Available Strategies

Strategy Behavior Use Case
manual Save for manual resolution Critical data requiring review
source_wins Always use source data One-way sync from authoritative source
target_wins Always use target data Preserving local modifications
newest_wins Use most recent timestamp General bidirectional sync

Manual Resolution

For critical data, use manual resolution to review each conflict:

1
2
3
4
5
{
  "options": {
    "conflict_strategy": "manual"
  }
}

Viewing Conflicts

List All Conflicts

Retrieve conflicts from a sync session:

1
2
curl -X GET "https://api.pinkcloudsync.example/v1/conflicts?session_id=550e8400-e29b-41d4-a716-446655440000&status=unresolved" \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import requests

url = "https://api.pinkcloudsync.example/v1/conflicts"

headers = {
    "Authorization": f"Bearer {access_token}"
}

params = {
    "session_id": "550e8400-e29b-41d4-a716-446655440000",
    "status": "unresolved",
    "limit": 50
}

response = requests.get(url, headers=headers, params=params)
data = response.json()

print(f"Found {data['total']} conflicts")
for conflict in data['conflicts']:
    print(f"\nConflict ID: {conflict['id']}")
    print(f"Record: {conflict['record_id']}")
    print(f"Source: {conflict['source_data']}")
    print(f"Target: {conflict['target_data']}")

Response

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
{
  "conflicts": [
    {
      "id": "660e8400-e29b-41d4-a716-446655440001",
      "session_id": "550e8400-e29b-41d4-a716-446655440000",
      "status": "unresolved",
      "record_id": "user_123",
      "source_data": {
        "name": "John Doe",
        "email": "john.doe@example.com",
        "updated_at": "2025-01-03T09:00:00Z"
      },
      "target_data": {
        "name": "John Smith",
        "email": "john.doe@example.com",
        "updated_at": "2025-01-03T09:30:00Z"
      },
      "created_at": "2025-01-03T10:05:00Z"
    }
  ],
  "total": 1,
  "limit": 50,
  "offset": 0
}

Resolving Conflicts

Use Source Data

Resolve by keeping the source version:

1
2
3
4
5
6
curl -X POST https://api.pinkcloudsync.example/v1/conflicts/660e8400-e29b-41d4-a716-446655440001/resolve \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "strategy": "use_source"
  }'
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
import requests

conflict_id = "660e8400-e29b-41d4-a716-446655440001"
url = f"https://api.pinkcloudsync.example/v1/conflicts/{conflict_id}/resolve"

headers = {
    "Authorization": f"Bearer {access_token}",
    "Content-Type": "application/json"
}

payload = {
    "strategy": "use_source"
}

response = requests.post(url, headers=headers, json=payload)
resolved = response.json()

print(f"Conflict resolved: {resolved['status']}")

Use Target Data

Resolve by keeping the target version:

1
2
3
{
  "strategy": "use_target"
}

Merge Data

Combine fields from both versions:

1
2
3
4
5
6
curl -X POST https://api.pinkcloudsync.example/v1/conflicts/660e8400-e29b-41d4-a716-446655440001/resolve \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "strategy": "merge"
  }'

Merge Strategy

The merge strategy automatically combines non-conflicting fields and uses the newest value for conflicting fields.

Custom Resolution

Provide your own data:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
curl -X POST https://api.pinkcloudsync.example/v1/conflicts/660e8400-e29b-41d4-a716-446655440001/resolve \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "strategy": "custom",
    "custom_data": {
      "name": "John D. Smith",
      "email": "john.doe@example.com",
      "updated_at": "2025-01-03T10:00:00Z"
    }
  }'
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
payload = {
    "strategy": "custom",
    "custom_data": {
        "name": "John D. Smith",
        "email": "john.doe@example.com",
        "updated_at": "2025-01-03T10:00:00Z"
    }
}

response = requests.post(url, headers=headers, json=payload)

Next Steps


  1. A conflict occurs when the same data has been modified in both source and target systems, requiring a decision on which version to keep.