[plugin-coverage] resolve config/codeowners blob sha at the reported commit#2311
Merged
nikita-tkachenko-datadog merged 3 commits intoMay 11, 2026
Conversation
…commit
Coverage uploads previously computed the blob SHA of code-coverage.datadog.{yml,yaml}
and CODEOWNERS via `git rev-parse HEAD:<path>`, while the commit SHA reported in
the same payload comes from CI env vars (GIT_HEAD_SHA || GIT_SHA). When local HEAD
and the reported commit diverge — common on GitHub Actions PR builds (synthetic
merge ref vs PR head SHA), with DD_GIT_COMMIT_SHA overrides, or any detached-HEAD
setup — the resulting (commit, path, blob_sha) triple is internally inconsistent:
the file may exist at HEAD but not at the reported commit.
The downstream ci-coverage-splitter then asks source-code-query for that triple
and gets NotFound (rpc error: code = NotFound desc = resource not found), causing
the event to be rejected/stashed and coverage to silently disappear for the build.
Resolve the blob SHA against the same commit that goes on the wire so the triple
is consistent by construction. If the file isn't present at that commit,
`getRepoFile` returns undefined and the splitter falls back to its gitdb lookup
as before.
Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The fallback `spanTags[GIT_HEAD_SHA] || spanTags[GIT_SHA]` is what ends up on the wire (api.ts spreads `...payload.spanTags`, splitter reads it as `coalesce(HeadSHA, SHA)`). Three call sites in upload.ts had it inline; extract a tiny helper so they can't drift from each other or from the wire format. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
- getGitFileHash: lock in HEAD-by-default and ref-forwarding behavior - getRepoFile: short-circuit when git or ref is missing, resolve against the provided ref, and fall through to the next candidate path on miss Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Drarig29
approved these changes
May 11, 2026
nikita-tkachenko-datadog
deleted the
nikita.tkachenko/coverage-config-blob-sha-at-reported-commit
branch
May 11, 2026 12:37
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
code-coverage.datadog.{yml,yaml}andCODEOWNERSfrom local HEAD (git rev-parse HEAD:<path>), while the commit SHA on the same payload comes from CI env vars (GIT_HEAD_SHA || GIT_SHA). Those two values aren't tied to each other — when they diverge, the splitter receives a(commit, path, blob_sha)triple where the file isn't actually in the reported commit's tree.ci-coverage-splitterto callsource-code-query.GetCodeContentwith that triple, getNotFound: resource not found, retry 10× (NotFound is treated as transient), then reject/stash the event. Coverage silently disappears for that build.git rev-parse <reportedCommit>:<path>). The triple becomes internally consistent by construction; if the file isn't at that commit,getRepoFilereturnsundefinedand the splitter falls back to its gitdb lookup as before.Why local HEAD and the reported commit diverge in practice
refs/pull/N/mergeref; HEAD's tree contains files brought in by merging with the base, butGITHUB_SHA(and therefore the reported commit) is the PR head. Files added on base only land in the merge tree, not at the PR head.DD_GIT_COMMIT_SHA/--git-commit-shaoverrides the commit reported on the payload but not the blob computation.Repro that motivated this
A real prod failure: ci-coverage-splitter rejected events for
github.com/gojitsucom/mobile-warehouse-flutterwithcommit_sha:c0f9b4840cca576286661e5af25b666261e56919— gitdb tree at that commit has 2,015 files, none namedcode-coverage.datadog.yml.(path, blob_sha):code-coverage.datadog.yml,dbf70404459f7c35ee75ae1621e8a4af4c128af2.f71ded839e08d43c221fa827c39801320c343d1cdoes containcode-coverage.datadog.yml, and its blob SHA there is exactlydbf70404459f7c35ee75ae1621e8a4af4c128af2— i.e. the upload was generated when local HEAD pointed atf71ded8…while CI declaredc0f9b484…as the commit.After this change, the blob sha is taken from
c0f9b484…:code-coverage.datadog.yml, which doesn't exist →getRepoFilereturnsundefined→ splitter falls back to gitdb (which won't find it either, but that path is handled gracefully and doesn't reject the event).Test plan
yarn buildcleanyarn lintcleanyarn test packages/plugin-coverage packages/base/src/commands/git-metadata— all 160 tests passgetRepoFilereturnsundefined(no event rejection downstream).🤖 Generated with Claude Code