Merge commits can take the PR head as parent, dropping carryforward flags on the base branch

Aperta
#994 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
git, github
Ambito
backend

Direzione di ricerca

The report identifies apps/worker/services/repository.py, especially fetch_appropriate_parent_for_commit and _possibly_filter_out_branch, as the parent selection path. Read those functions alongside the merge handling in apps/worker/tasks/sync_pull.py, then trace how git parent order reaches the database query. Done means merge commits select the first git parent for the base branch and tests cover the case where both parents are stored on that branch.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Summary

When a PR is merged with a merge commit (not squash/rebase), Codecov can pick the PR head as the parent of the merge commit on the base branch instead of the previous base-branch commit (the first git parent). With carryforward flags, the base branch then inherits the PR branch's report, so flags the PR never uploaded disappear from the base branch, or roll back to stale values.

In our repo (39 carryforward flags, CI runs only affected projects per PR) this happens on roughly half of merges. After about a week, 27 of the 39 flags had no coverage on main's head, and PRs showed (?) / "No coverage information found on base report" for them.

Root cause (worker source, codecov/umbrella @ 6d449dd)

  1. apps/worker/tasks/sync_pull.py (L396-L420): when a PR is merged without squash, every commit on the PR including pull.head is updated to branch=<base branch>, merged=True.
  2. apps/worker/services/repository.py fetch_appropriate_parent_for_commit (L109-L157): the merge commit's git parents are looked up, and both exist in Codecov's DB (the previous main commit from the push upload, the PR head from PR CI).
  3. _possibly_filter_out_branch (L160-L170) returns the first row whose branch equals the commit's branch. After step 1, both parents have branch=main. The query has no ORDER BY, and git parent order is never consulted, so whichever row the DB returns first wins.

Empirically the row with the lexicographically smaller commit SHA wins: that held for every merge commit we checked (19 of 19), and it picks the PR head about half the time.

Expected

For a merge commit, prefer the first git parent (the previous commit on the base branch), e.g. preserve git_commit["parents"] order in _possibly_filter_out_branch instead of relying on the unordered query result.

Things we tried that don't help

  • Uploading with an explicit parent (commit_parent in codecov-action v5 / --parent-sha in the CLI): the stored parent is still the one chosen above.
  • No codecov.yml key controls parent selection.
  • Changing the merge strategy to squash avoids it, but that isn't an option for us.

Environment

  • GitHub, Codecov GitHub App, codecov/codecov-action@v5
  • Carryforward on all flags, strict_yaml_branch: main, merge-commit merges
Lingua principale
Nessun dato sulla lingua
Stelle
52
Fork
26
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di codecov/feedback

Tutte le issue di codecov/feedback

Issue simili

Altre issue su Backend & API Design

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.