Skip to content

[BUG] sync-main-to-dev conflict detection always reports false positives #410

@c-vigo

Description

@c-vigo

Description

The "Detect merge conflicts" step in sync-main-to-dev.yml always reports conflict=true, even when dev is a strict ancestor of main and conflicts are mathematically impossible. This causes every sync PR to be mislabeled as merge-conflict and auto-merge is never enabled.

Steps to Reproduce

  1. Push to main (triggers sync-main-to-dev workflow)
  2. Workflow runs "Detect merge conflicts" step
  3. git merge --no-commit --no-ff origin/main 2>/dev/null returns non-zero
  4. PR is created with (conflicts) title and merge-conflict label
  5. "Enable auto-merge" step is skipped

Expected Behavior

When dev is behind main with no divergent commits, the conflict check should report conflict=false, the PR should have a clean title, no merge-conflict label, and auto-merge should be enabled.

Actual Behavior

Every run reports false conflicts. Verified across 5 consecutive runs in downstream (vig-os/devcontainer-smoke-test) and 1 run in upstream (vig-os/devcontainer). Evidence from PR #59: GitHub API confirms mergeStateStatus: CLEAN and mergeable: MERGEABLE, branch compare shows dev is 0 ahead / 3 behind main.

Environment

  • Upstream: ubuntu-22.04 runner, git 2.53.0
  • Downstream: ghcr.io/vig-os/devcontainer container on ubuntu-22.04, git 2.39.5
  • Bug reproduces in both environments

Additional Context

The exact cause of the git merge non-zero exit is unknown because 2>/dev/null suppresses all error output. The step does not distinguish between actual conflicts (exit 1) and other failures (exit 128+).

Affected workflow runs (downstream): 23402800270, 23382600708, 23382437352, 23381148959, 23339310830. Upstream: 23060324149.

Both .github/workflows/sync-main-to-dev.yml (upstream) and the downstream copy are affected.

Possible Solution

  1. Remove or replace 2>/dev/null — capture stderr for logging
  2. Distinguish exit codes: 1 = conflict, other = unexpected error
  3. Add a fast-path: git merge-base --is-ancestor origin/dev origin/main → skip conflict check (conflicts impossible when dev is an ancestor)
  4. Consider git merge-tree --write-tree (git 2.38+) for in-memory merge without working-tree side effects

Changelog Category

Fixed


  • TDD compliance (see .cursor/rules/tdd.mdc)

Metadata

Metadata

Assignees

Labels

area:ciCI/CD, GitHub Actions, workflowsbugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions