Resolve merge conflicts
Merge conflicts occur when the same infrastructure object is modified differently in both the source and destination branches. This guide shows you how to identify, review, and resolve conflicts in Infrahub.Prerequisites
Before resolving merge conflicts, ensure you have:- An existing proposed change with detected conflicts
- Appropriate permissions to resolve conflicts and merge changes
- Understanding of the changes in both branches
Understand conflicts in Infrahub
Unlike traditional text-based version control, Infrahub detects conflicts at the data level—identifying specific attribute and relationship conflicts within objects.Conflict types
Attribute conflicts occur when:- The same attribute is changed to different values in each branch
- An attribute is modified in one branch and the object is deleted in another
- The same relationship points to different objects in each branch
- A relationship is added/removed in one branch while modified in another
- An object is modified in one branch but deleted in another
- An object is added in both branches with different data
backend/infrahub/core/diff/conflicts_enricher.py:34 for implementation details.
Detect conflicts
Infrahub automatically detects conflicts when you create a proposed change or when the destination branch changes.Check for conflicts
Query a proposed change to see if conflicts exist:kind: "DataIntegrity"conclusion: "failure"- Message indicating conflicts
Validate branch for conflicts
Use theBranchValidate mutation to check for conflicts:
ok: true) indicates no conflicts. A failure indicates conflicts that must be resolved.
See BranchValidate mutation at backend/infrahub/graphql/mutations/branch.py:228.
View conflict details
Retrieve detailed information about specific conflicts in the diff.Query conflicts in diff
uuid: Unique identifier for the conflictbase_branch_action: Action in the destination branch (ADDED,UPDATED,REMOVED)base_branch_value: Value in the destination branchdiff_branch_action: Action in the source branchdiff_branch_value: Value in the source branchselected_branch: Which branch’s value was chosen (if resolved)
Resolve conflicts
For each conflict, choose which branch’s value to keep. Conflicts can be resolved at the node, attribute, or relationship level.Resolve an attribute conflict
Choose which branch’s value to keep for a specific attribute:conflict_id: UUID of the conflict to resolveselected_branch: Which branch to use (source_branchordestination_branch)
Resolve a node conflict
When an object is modified in one branch but deleted in another:destination_branch keeps the deletion, while source_branch keeps the modifications.
Resolve a relationship conflict
Rebase to update with main
Rebasing updates your branch with the latest changes from main, which can help identify conflicts early.Rebase a branch
wait_until_completion(optional, default:true): Wait for rebase to complete
- Updates
branched_fromto the current time - Incorporates all changes from main since the original branch point
- Identifies conflicts with main
- Re-runs migrations if schema changes exist
backend/infrahub/graphql/mutations/branch.py:184 and rebase_branch task at backend/infrahub/core/branch/tasks.py:110.
Rebase requirements
Before rebasing, ensure:- No unresolved conflicts exist in the diff
- The branch status is
OPENorNEED_REBASE - You have reviewed the changes in main since branching
- Conflicts exist between the branch and main
- Schema migrations are required but fail validation
- The branch status is
NEED_UPGRADE_REBASE
Common conflict scenarios
Scenario 1: Conflicting attribute values
Situation:- Main branch: Device hostname changed to
router-01-nyc - Feature branch: Same device hostname changed to
router-core-nyc
Scenario 2: Object modified vs. deleted
Situation:- Main branch: Device deleted
- Feature branch: Device IP address updated
Scenario 3: Relationship conflicts
Situation:- Main branch: Interface connected to Switch-A
- Feature branch: Same interface connected to Switch-B
Verify conflict resolution
After resolving all conflicts, verify the proposed change is ready to merge.Check resolution status
- All conflicts have a
selected_branchvalue - Data integrity check shows
conclusion: "success"
Re-run validation
Trigger validation checks after resolving conflicts:Best practices
Rebase before creating proposed changes
Update your branch with main before creating a proposed change:- Rebase the branch to incorporate latest main changes
- Resolve any conflicts in your branch
- Create the proposed change with a clean diff
Document conflict decisions
When resolving conflicts, add comments explaining your decision:Coordinate with team members
Before resolving conflicts:- Review the changes in both branches
- Understand the intent of each change
- Consult with the authors if unclear
- Document the resolution reasoning
Related resources
- Work with branches - Create and manage branches
- Proposed changes - Review and merge changes
- Proposed change topic - Understand conflict resolution workflows
- Branching topic - Learn about branch isolation and merge semantics