Skip to content

fix(worker): fallback to latest known default-branch parent when provider ancestry isn't in DB#724

Open
nikosatwork wants to merge 1 commit intocodecov:mainfrom
nikosatwork:fix/worker-base-commit-parent-fallback
Open

fix(worker): fallback to latest known default-branch parent when provider ancestry isn't in DB#724
nikosatwork wants to merge 1 commit intocodecov:mainfrom
nikosatwork:fix/worker-base-commit-parent-fallback

Conversation

@nikosatwork
Copy link

Summary

This PR adds a default-branch fallback in worker parent selection when provider-reported ancestry cannot be matched to known commits in DB.

If the commit is on the repository default branch and normal ancestry lookup fails, worker now selects the latest earlier known commit on that same default branch.

Why

In some cases provider ancestry is unavailable or not yet represented in DB, which can leave parent selection unresolved even when there is clear recent default-branch history already known to Codecov.

This fallback reduces “missing parent/base” outcomes for default-branch commits while preserving existing behavior for non-default branches.

What changed

  • repository.py
    • In fetch_appropriate_parent_for_commit, after existing parent/ancestor strategies fail, add a fallback:
      • only for default-branch commits
      • query same-repo, same-branch, non-deleted commits with non-null message
      • only commits earlier than current commit timestamp (when present)
      • select most recent by timestamp
  • test_repository_service.py
    • Added test: default-branch commit falls back to latest previous known commit when ancestors are unknown
    • Added test: non-default branch does not use this fallback when ancestors are unknown

Scope

  • Scoped to worker parent selection fallback and its repository service tests.
  • Main risk is behavior change for default-branch parent selection when ancestry is unavailable.
  • Mitigated by explicit positive/negative test coverage for fallback behavior.

Validation

  • Targeted worker parent-selection tests pass.
  • Lint and format checks were run per repository guidance.

Related

Closes codecov/feedback#861

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. In 2022 this entity acquired Codecov and as result Sentry is going to need some rights from me in order to utilize my contributions in this PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

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.

Missing base commit on main despite earlier covered ancestors

1 participant