Prefer checked-out Git metadata over CI environment values #2658
<a target='_blank' href='https://app.datadoghq.com/ci/test/runs?query=test_level%3Atest+%40git.commit.sha%3Ab101af38ecbdecb5cd96b906ecad5be8be05d0e1&referrer=pr-comment&start=1795773514000'><picture><source media="(prefers-color-scheme: dark)" srcset="https://static.datadoghq.com/static/images/pr_comments/software_delivery/badges_header/tests-warning.svg"/><img src="https://static.datadoghq.com/static/images/pr_comments/software_delivery/badges_header/tests-warning-light.svg" alt="Tests" align="center" /></picture></a> <a target='_blank' href='https://app.datadoghq.com/ci/pipeline-executions?query=ci_level%3Ajob+%40git.commit.sha%3Ab101af38ecbdecb5cd96b906ecad5be8be05d0e1&referrer=pr-comment&start=1795773514000'><picture><source media="(prefers-color-scheme: dark)" srcset="https://static.datadoghq.com/static/images/pr_comments/software_delivery/badges_header/pipelines-ok.svg"/><img src="https://static.datadoghq.com/static/images/pr_comments/software_delivery/badges_header/pipelines-ok-light.svg" alt="Pipelines" align="center" /></picture></a>
⚠️ Warnings
Your PR has warnings. Please review the issues below.
❄️ 1 New flaky test detected
<blockquote>
<div>
<details>
<summary><code>getSpanTags prefers the checkout over CI metadata, with or without an explicit Git path</code> from <code>packages/base/src/helpers/__tests__/tags.test.ts</code></summary>
expect(received).toEqual(expected) // deep equality
Expected: "https://www.github.com/datadog/safe-repository"
Received: "https://www.github.com/datadog/not-so-safe-repository"
</details>
</div>
<a href="https://app.datadoghq.com/ci/test/flaky?query=-flaky_test_state%3Afixed+fix_in_progress%3Afalse+first_flaked_branch%3A%22juan-fernandez%2Fci-provider-git-metadata%22+%40git.repository.id_v2%3A%22github.com%2Fdatadog%2Fdatadog-ci%22+fingerprint_fqn%3A%28%22318e4765fc852e1e%22%29&referrer=pr-comment">View in Flaky Test Management</a>
</blockquote>
ℹ️ Info
<details><summary>No other issues found (see more)</summary>
🧪 All tests passed
</details>
Useful? React with 👍 / 👎
<sub>
This comment will be updated automatically if new data arrives. <br />
🔗 Commit SHA: b101af3 | <a href="https://docs.datadoghq.com/integrations/guide/source-code-integration/#pr-comments">Docs</a> | <a href="https://app.datadoghq.com/ci/pull-request/Z2l0aHViLmNvbS9kYXRhZG9nL2RhdGFkb2ctY2kvMjY1OA==?referrer=pr-comment">View more details</a> | Give us <a href="https://dd.enterprise.slack.com/archives/C07E3U2QRMM">feedback</a>!
</sub>
/datadog autotest review
@codex review
<!-- codex-pull-request-review-summary -->
<!-- codex-review-state:v1 {"code_review":{"commit_sha":"b101af38ecbdecb5cd96b906ecad5be8be05d0e1","has_any_findings":false,"has_unresolved_findings":false,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} -->
<details>
<summary><strong>Codex Review Summary</strong>: ✅ Completed</summary>
This comment shows the latest Codex review activity on this pull request.
| Review | Status | Commit | Review trigger |
| --- | --- | --- | --- |
| 📝 Code Review | ✅ Completed <relative-time datetime="2026-11-27T10:32:37.842587Z">2026-11-27T10:32:37.842587Z</relative-time> | b101af3 | Manual request |
<details> <summary>ℹ️ About Codex in GitHub</summary>
<br/>
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
</details>
</details>
<!-- codex-review-receipt:v1 -->
Codex Review: Didn't find any major issues. Hooray!
Reviewed commit: 9d9c27efb3
<details> <summary>ℹ️ About Codex in GitHub</summary>
<br/>
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
</details>
<!-- datadog-code-review reviewer-id=bad90057-5c12-4101-ad47-d91c9dff0f90 -->
<!-- datadog-autotest-inline:v1:prod -->
<!-- datadog-autotest-delivery:v1:prod:7b486214aa9ac2bb42f5bda69b4a4976a1f5f9f23446e653afde9ec50fa30c56:inline-0 -->
<sub><sub>!P2</sub></sub> Preserve path components in GitLab target branch names
<!-- autotest-finding-meta prod_data_type=none finding_id=d1b74931-f989-4364-af0d-35629b3dfcda prod_effect=static -->
For GitLab merge requests targeting valid branches such as release/tags/v1 or release/origin/v1, the new normalization reports release/v1. This was reproduced through getCISpanTags(): normalizeRef removes these components anywhere in the string, causing JUnit and coverage uploads to carry incorrect target-branch metadata. Strip only the leading ref prefix.
tags[GIT_PULL_REQUEST_BASE_BRANCH] = CI_MERGE_REQUEST_TARGET_BRANCH_NAME?.replace(/^refs\/heads\//, '')
<!-- datadog-autotest-feedback-legend:v1 -->
React: 👍 useful · 👎 wrong · 😕 unclear · 👀 right, but not acting on it
<details><summary>What each reaction means</summary>
</details>
<sub>🤖 Bits Code Review</sub> <sub>· <a href="https://app.datadoghq.com/code/b99e9d90-8615-4204-aa4f-4b7632fbd4a0?referrer=autotest-pr-comment">Open Bits AI session</a></sub>
GitLab target-branch normalization corrupts valid names containing tags/ or origin/, producing incorrect metadata in JUnit and coverage uploads. A localized replacement preserves those names and existing GitLab fixture expectations.
<sub>Open Bits AI session</sub>
<sub>🤖 Bits Code Review · Commit 9d9c27e</sub>
<!-- autotest-meta model=gpt-6.1-sol engine=codex reasoning_effort=high verdict=FAIL ddrs_bucket=unknown session_id=b99e9d90-8615-4204-aa4f-4b7632fbd4a0 -->
<!-- datadog-code-review reviewer-id=bad90057-5c12-4101-ad47-d91c9dff0f90 -->
<!-- datadog-autotest:v1:prod -->
<!-- datadog-autotest-delivery:v1:prod:7b486214aa9ac2bb42f5bda69b4a4976a1f5f9f23446e653afde9ec50fa30c56:bundle -->
Fixed in 1e2a707de895a57d76e22dca488563a2c70e359e. GitLab target branches now strip only a leading refs/heads/ prefix, preserving tags/, origin/, and embedded refs/heads/ components. Added eight parser regression cases: seven reproduce the corruption before the fix; all eight pass afterward. Build, lint, all 1,172 affected tests, and all 337 CI-spec tests pass.
/datadog autotest review
@codex review
<!-- codex-review-receipt:v1 -->
Codex Review: Didn't find any major issues. Breezy!
Reviewed commit: 1e2a707de8
<details> <summary>ℹ️ About Codex in GitHub</summary>
<br/>
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
</details>
<!-- datadog-code-review reviewer-id=bad90057-5c12-4101-ad47-d91c9dff0f90 -->
<!-- datadog-autotest-inline:v1:prod -->
<!-- datadog-autotest-delivery:v1:prod:8fee92cdfb25ec6f6f5aaae511c79132e98c1deff0e54891d125accac00c2389:inline-0 -->
<sub><sub>!P1</sub></sub> Map the merge SHA tag before emitting shell assignments
<!-- autotest-finding-meta prod_data_type=none finding_id=48b52ffb-f71e-4f99-8bd9-385f40f904f7 prod_effect=static -->
On PR merge builds, this tag reaches ci-env read, but TAG_TO_ENV_VAR in packages/base/src/commands/ci-env/read.ts has no mapping for it. Default output therefore includes ci.git.merge_commit_sha='…', which Bash treats as a command. Reproduced with GITHUB_REF=refs/pull/42/merge and a valid SHA: ci-env read returned 0, but loading its output under bash -e exited 127, aborting the CI script. Add an explicit shell-safe DD_* mapping in read.ts and cover this merge-build output in its tests.
<!-- datadog-autotest-feedback-legend:v1 -->
React: 👍 useful · 👎 wrong · 😕 unclear · 👀 right, but not acting on it
<details><summary>What each reaction means</summary>
</details>
<sub>🤖 Bits Code Review</sub> <sub>· <a href="https://app.datadoghq.com/code/0276637b-9b17-4394-bf48-8f0de6551aff?referrer=autotest-pr-comment">Open Bits AI session</a></sub>
On PR merge builds, ci-env read emits the new dotted tag name as a Bash assignment, causing documented shell-loading usage to fail with exit code 127.
<sub>Open Bits AI session</sub>
<sub>🤖 Bits Code Review · Commit 1e2a707</sub>
<!-- autotest-meta model=gpt-6.1-sol engine=codex reasoning_effort=high verdict=FAIL ddrs_bucket=unknown session_id=0276637b-9b17-4394-bf48-8f0de6551aff -->
<!-- datadog-code-review reviewer-id=bad90057-5c12-4101-ad47-d91c9dff0f90 -->
<!-- datadog-autotest:v1:prod -->
<!-- datadog-autotest-delivery:v1:prod:8fee92cdfb25ec6f6f5aaae511c79132e98c1deff0e54891d125accac00c2389:bundle -->
Fixed in 2d120ab865e68811987953544c857ac3d146c000. Added the explicit DD_CI_GIT_MERGE_COMMIT_SHA mapping for Bash and JSON output; --format tags retains ci.git.merge_commit_sha. Added eight command-level regressions covering all affected providers and output formats. The real built CLI reproduced exit 127 for both documented eval and source examples before the fix; both now exit 0 and retain the expected merge SHA. Build, lint, all 1,192 affected tests, and all 337 CI-spec tests pass.
/datadog autotest review
@codex review
<!-- codex-review-receipt:v1 -->
Codex Review: Didn't find any major issues. Another round soon, please!
Reviewed commit: 2d120ab865
<details> <summary>ℹ️ About Codex in GitHub</summary>
<br/>
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
</details>
<details>
<summary>More details</summary>
Merge-commit metadata stays separate from PR source SHAs. The reviewed head includes the GitLab branch-prefix and shell-export fixes described in the human discussion, and the static reviewer returned no actionable findings.
</details>
Was this helpful? React 👍 or 👎
<sub>Open Bits AI session</sub>
<sub>🤖 Bits Code Review · Commit 2d120ab</sub>
<!-- autotest-meta model=gpt-6.1-sol engine=codex reasoning_effort=high verdict=PASS ddrs_bucket=unknown session_id=f4dad94d-17b3-4d6e-a5da-0a4c121ce7d0 -->
<!-- datadog-code-review reviewer-id=bad90057-5c12-4101-ad47-d91c9dff0f90 -->
<!-- datadog-autotest:v1:prod -->
<!-- datadog-autotest-delivery:v1:prod:d92dceef2f5a68e2b24620830f41b3eb37dea4fc0e7153aeda8ea780f196a31f:bundle -->
<!-- datadog-code-review reviewer-id=bad90057-5c12-4101-ad47-d91c9dff0f90 -->
<!-- datadog-autotest-inline:v1:prod -->
<!-- datadog-autotest-delivery:v1:prod:5595c37f8c3a3a8168e1bd603e0a955ebdf205f7e45db2a731bb8bed981f8af8:inline-0 -->
<sub><sub>!P2</sub></sub> Preserve merge SHA when reloading exported CI variables
<!-- autotest-finding-meta prod_data_type=none finding_id=1c60c2ac-fab5-414a-88a8-1eeeb193825f prod_effect=static -->
When exported CI variables are passed into a container without the original provider variables, the new merge SHA is lost because getUserCISpanTags() never reads DD_CI_GIT_MERGE_COMMIT_SHA. A focused CLI reproduction exported a GitHub PR merge environment and reloaded that output: DD_GIT_COMMIT_SHA survived, but DD_CI_GIT_MERGE_COMMIT_SHA disappeared. Add normalized input handling in getUserCISpanTags() and round-trip coverage so this handoff preserves the merge metadata.
<!-- datadog-autotest-feedback-legend:v1 -->
React: 👍 useful · 👎 wrong · 😕 unclear · 👀 right, but not acting on it
<details><summary>What each reaction means</summary>
</details>
<sub>🤖 Bits Code Review</sub> <sub>· <a href="https://app.datadoghq.com/code/d08cc8f9-bf70-4ce4-97e7-b3c8f59da882?referrer=autotest-pr-comment">Open Bits AI session</a></sub>
Exported CI environments lose ci.git.merge_commit_sha when reloaded without provider variables, even though git.commit.sha survives.
<sub>Open Bits AI session</sub>
<sub>🤖 Bits Code Review · Commit 2d120ab</sub>
<!-- autotest-meta model=gpt-6.1-sol engine=codex reasoning_effort=high verdict=FAIL ddrs_bucket=unknown session_id=d08cc8f9-bf70-4ce4-97e7-b3c8f59da882 -->
<!-- datadog-code-review reviewer-id=bad90057-5c12-4101-ad47-d91c9dff0f90 -->
<!-- datadog-autotest:v1:prod -->
<!-- datadog-autotest-delivery:v1:prod:5595c37f8c3a3a8168e1bd603e0a955ebdf205f7e45db2a731bb8bed981f8af8:bundle -->
@juan-fernandez what do you think of this?
LGTM as admin
Agreed — this was a real gap. Fixed in ed6d75d0d2619455e4283f7900e0d51349257a1f: getUserCISpanTags() now reads and normalizes valid DD_CI_GIT_MERGE_COMMIT_SHA values. Added a CLI round-trip regression that exports GitHub PR metadata and reloads only the exported variables, without the original provider environment; both the selected commit SHA and separate CI merge SHA survive. Empty or malformed imported values do not replace valid provider metadata.
/datadog autotest review
@codex review
<!-- codex-review-receipt:v1 -->
Codex Review: Didn't find any major issues. You're on a roll.
Reviewed commit: ed6d75d0d2
<details> <summary>ℹ️ About Codex in GitHub</summary>
<br/>
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
</details>
/datadog autotest review
@codex review
<sub><sub>!P2 Badge</sub></sub> Preserve the branch for matched detached PR-head checkouts
In a GitHub Actions pull-request job that checks out the event's head SHA rather than the synthetic merge SHA, the checkout can be detached at the same workspace root, with its revision matching provider[GIT_HEAD_SHA]. The relationship check above recognizes this case, but this fallback only checks the provider's main and merge SHAs, so it discards GITHUB_HEAD_REF and returns no git.branch. This regresses SARIF and SBOM uploads: their getMissingRequiredGitTags() validation requires a branch and returns exit code 1 before uploading. Allow a matching PR-head revision to recover the CI branch as well, without replacing unrelated checkout metadata.
Useful? React with 👍 / 👎.
<!-- codex-code-review-finding:v1 -->
<!-- codex-review-receipt:v1 -->
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ea15a59336
<details> <summary>ℹ️ About Codex in GitHub</summary>
<br/>
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
</details>
<!-- datadog-code-review reviewer-id=bad90057-5c12-4101-ad47-d91c9dff0f90 -->
<!-- datadog-autotest-inline:v1:prod -->
<!-- datadog-autotest-delivery:v1:prod:198983bf62d13120b1aee473e6384f7cbb9fcdc233fa6d3c7f9e404dd0b59505:inline-0 -->
<sub><sub>!P1</sub></sub> Preserve detached checkout branches across container mounts
<!-- autotest-finding-meta prod_data_type=none finding_id=d2afbde8-4f33-4dab-9594-15566c6248d8 prod_effect=static -->
When a detached CI checkout is mounted at a different path from ci.workspace_path, matchingRoot is false even when its repository URL and SHA match. A focused resolver reproduction with stubbed checkout reads returned no git.branch. SARIF and SBOM uploads consequently fail their required-tag checks. Matching needs a repository-identity fallback with consistent safeguards for unrelated checkouts.
<!-- datadog-autotest-feedback-legend:v1 -->
React: 👍 useful · 👎 wrong · 😕 unclear · 👀 right, but not acting on it
<details><summary>What each reaction means</summary>
</details>
<sub>🤖 Bits Code Review</sub> <sub>· <a href="https://app.datadoghq.com/code/17e74bc0-e73b-4877-b578-ee7f4032a9e4?referrer=autotest-pr-comment">Open Bits AI session</a></sub>
<!-- datadog-code-review reviewer-id=bad90057-5c12-4101-ad47-d91c9dff0f90 -->
<!-- datadog-autotest-inline:v1:prod -->
<!-- datadog-autotest-delivery:v1:prod:198983bf62d13120b1aee473e6384f7cbb9fcdc233fa6d3c7f9e404dd0b59505:inline-1 -->
<sub><sub>!P1</sub></sub> Restore branch metadata for detached PR head checkouts
<!-- autotest-finding-meta prod_data_type=none finding_id=ac077f3d-bda1-4b17-8f1c-ae205c1d6e7e prod_effect=static -->
For GitHub PR jobs checking out github.event.pull_request.head.sha, the detached checkout matches GIT_HEAD_SHA rather than the synthetic merge SHA. This restoration condition excludes that match and discards GITHUB_HEAD_REF's valid branch. A focused resolver reproduction confirmed the missing branch, which also blocks SARIF/SBOM uploads. Include the PR head SHA when restoring detached-checkout metadata.
[provider[GIT_SHA], provider[CI_GIT_MERGE_COMMIT_SHA], provider[GIT_HEAD_SHA]].some((sha) =>
sameSha(sha, checkout[GIT_SHA])
)
<!-- datadog-autotest-feedback-legend:v1 -->
React: 👍 useful · 👎 wrong · 😕 unclear · 👀 right, but not acting on it
<details><summary>What each reaction means</summary>
</details>
<sub>🤖 Bits Code Review</sub> <sub>· <a href="https://app.datadoghq.com/code/17e74bc0-e73b-4877-b578-ee7f4032a9e4?referrer=autotest-pr-comment">Open Bits AI session</a></sub>
<!-- datadog-code-review reviewer-id=bad90057-5c12-4101-ad47-d91c9dff0f90 -->
<!-- datadog-autotest-inline:v1:prod -->
<!-- datadog-autotest-delivery:v1:prod:198983bf62d13120b1aee473e6384f7cbb9fcdc233fa6d3c7f9e404dd0b59505:inline-2 -->
<sub><sub>!P2</sub></sub> Drop provider PR numbers for unrelated checkouts
<!-- autotest-finding-meta prod_data_type=none finding_id=9e898372-980e-4c7b-9c55-9e68b14d2364 prod_effect=static -->
When selecting an unrelated secondary checkout, this filter removes Git PR relationships but retains pr.number because it does not start with git. A focused resolver reproduction returned the secondary repository URL alongside the primary repository's PR number. getCoverageDetailsUrl combines these into an incorrect PR link. Gate the provider PR number on relatedCheckout while retaining explicit user overrides.
const relationship =
key === 'pr.number' || key.startsWith('git.commit.head.') || key.startsWith('git.pull_request.')
return relationship ? relatedCheckout : !key.startsWith('git.')
<!-- datadog-autotest-feedback-legend:v1 -->
React: 👍 useful · 👎 wrong · 😕 unclear · 👀 right, but not acting on it
<details><summary>What each reaction means</summary>
</details>
<sub>🤖 Bits Code Review</sub> <sub>· <a href="https://app.datadoghq.com/code/17e74bc0-e73b-4877-b578-ee7f4032a9e4?referrer=autotest-pr-comment">Open Bits AI session</a></sub>
The shared resolver drops required branch metadata for valid detached checkouts, blocking SARIF and SBOM uploads. It also retains the primary repository’s PR number when selecting an unrelated checkout.
<sub>Open Bits AI session</sub>
<sub>🤖 Bits Code Review · Commit ed6d75d</sub>
<!-- autotest-meta model=gpt-6.1-sol engine=codex reasoning_effort=high verdict=FAIL ddrs_bucket=unknown session_id=17e74bc0-e73b-4877-b578-ee7f4032a9e4 -->
<!-- datadog-code-review reviewer-id=bad90057-5c12-4101-ad47-d91c9dff0f90 -->
<!-- datadog-autotest:v1:prod -->
<!-- datadog-autotest-delivery:v1:prod:198983bf62d13120b1aee473e6384f7cbb9fcdc233fa6d3c7f9e404dd0b59505:bundle -->
<!-- datadog-code-review reviewer-id=bad90057-5c12-4101-ad47-d91c9dff0f90 -->
<!-- datadog-autotest-inline:v1:prod -->
<!-- datadog-autotest-delivery:v1:prod:6de7537e16491c8d6cd64f4b60cddb4d5abd2bf123f03affb4e7f7389187e6b6:inline-0 -->
<sub><sub>!P1</sub></sub> Keep tag-triggered SBOM and SARIF uploads working
<!-- autotest-finding-meta prod_data_type=none finding_id=36fa7e4b-fb1f-41f6-89db-28e426a4b75d prod_effect=static -->
On a GitHub Actions tag push with the default detached checkout and no branch override, gitCurrentBranch() returns empty and CI supplies only git.tag. A local reproduction confirmed that getMissingRequiredGitTags() then reports git.branch as missing. Both sbom upload and sarif upload use this validator and return 1, so previously working release uploads fail before sending reports. Update the affected validation and upload contracts to support tag-only checkouts.
<!-- datadog-autotest-feedback-legend:v1 -->
React: 👍 useful · 👎 wrong · 😕 unclear · 👀 right, but not acting on it
<details><summary>What each reaction means</summary>
</details>
<sub>🤖 Bits Code Review</sub> <sub>· <a href="https://app.datadoghq.com/code/bf6e3d9d-79d8-4f37-be6e-ed42ec52b92c?referrer=autotest-pr-comment">Open Bits AI session</a></sub>
<!-- datadog-code-review reviewer-id=bad90057-5c12-4101-ad47-d91c9dff0f90 -->
<!-- datadog-autotest-inline:v1:prod -->
<!-- datadog-autotest-delivery:v1:prod:6de7537e16491c8d6cd64f4b60cddb4d5abd2bf123f03affb4e7f7389187e6b6:inline-1 -->
<sub><sub>!P2</sub></sub> Preserve CI branch metadata for detached PR-head checkouts
<!-- autotest-finding-meta prod_data_type=none finding_id=e9b249a9-a33c-4b0a-a4c3-eaa60e099c44 prod_effect=static -->
When GitHub Actions checks out github.event.pull_request.head.sha, the detached checkout matches GIT_HEAD_SHA while GITHUB_SHA and the CI merge SHA identify the merge commit. This narrower condition excludes the head SHA, dropping the known GITHUB_HEAD_REF branch from JUnit, coverage, tracing, and CI exports. A local reproduction confirmed the missing branch; adding GIT_HEAD_SHA to this match restored it while retaining the checkout SHA and PR-head relationship.
[provider[GIT_SHA], provider[CI_GIT_MERGE_COMMIT_SHA], provider[GIT_HEAD_SHA]].some((sha) =>
sameSha(sha, checkout[GIT_SHA])
)
<!-- datadog-autotest-feedback-legend:v1 -->
React: 👍 useful · 👎 wrong · 😕 unclear · 👀 right, but not acting on it
<details><summary>What each reaction means</summary>
</details>
<sub>🤖 Bits Code Review</sub> <sub>· <a href="https://app.datadoghq.com/code/bf6e3d9d-79d8-4f37-be6e-ed42ec52b92c?referrer=autotest-pr-comment">Open Bits AI session</a></sub>
Detached tag checkouts can make SBOM and SARIF uploads fail their required-branch validation. Detached PR-head checkouts also lose a branch already known to CI.
<sub>Open Bits AI session</sub>
<sub>🤖 Bits Code Review · Commit ea15a59</sub>
<!-- autotest-meta model=gpt-6.1-sol engine=codex reasoning_effort=high verdict=FAIL ddrs_bucket=unknown session_id=bf6e3d9d-79d8-4f37-be6e-ed42ec52b92c -->
<!-- datadog-code-review reviewer-id=bad90057-5c12-4101-ad47-d91c9dff0f90 -->
<!-- datadog-autotest:v1:prod -->
<!-- datadog-autotest-delivery:v1:prod:6de7537e16491c8d6cd64f4b60cddb4d5abd2bf123f03affb4e7f7389187e6b6:bundle -->
Fixed in 01b085cd5fbee2038fe09252c0729eca7a54f585. Detached-checkout matching now includes the CI PR-head SHA alongside the provider and merge SHAs. Regression coverage uses a checkout at the PR head with a different CI merge SHA and verifies that its actual SHA, known CI branch, canonical URL and PR relationships survive. Repository/root and revision guards continue to exclude unrelated checkout metadata.
Fixed on the CLI side in 01b085cd5fbee2038fe09252c0729eca7a54f585. SARIF/SBOM validation now permits an absent branch, and the SBOM contract makes branch optional and omits it from the serialized commit instead of sending an empty string. Mocked command/request regressions cover both tag-only and untagged detached checkouts, retaining the actual SHA and known git.tag without inventing a branch. Also corrected refs/tags normalization so the real tag name survives. As confirmed by the author, backend acceptance of branchless uploads is being updated separately; this PR does not claim that backend change is deployed.
Fixed in 01b085cd5fbee2038fe09252c0729eca7a54f585. Provider pr.number now follows the same related-checkout guard as the PR-head/base fields, so an unrelated checkout cannot inherit the workflow repository's PR number. Explicit DD_PR_NUMBER still takes precedence. Tests cover unrelated repositories/revisions, matching PR context and the explicit override.
Fixed in 01b085cd5fbee2038fe09252c0729eca7a54f585. Detached-checkout matching now includes the CI PR-head SHA alongside the provider and merge SHAs. Regression coverage uses a checkout at the PR head with a different CI merge SHA and verifies that its actual SHA, known CI branch, canonical URL and PR relationships survive. Repository/root and revision guards continue to exclude unrelated checkout metadata.
Fixed in 01b085cd5fbee2038fe09252c0729eca7a54f585. A remounted checkout can retain known CI identity when its repository URL and a CI revision match, even when its mount path differs from ci.workspace_path. Tests cover both merge and PR-head revisions, different URLs/revisions, and literal local/file paths; ci.workspace_path remains unchanged. Native checks exercise real remounted checkouts as well.
Fixed in 01b085cd5fbee2038fe09252c0729eca7a54f585. Detached-checkout matching now includes the CI PR-head SHA alongside the provider and merge SHAs. Regression coverage uses a checkout at the PR head with a different CI merge SHA and verifies that its actual SHA, known CI branch, canonical URL and PR relationships survive. Repository/root and revision guards continue to exclude unrelated checkout metadata.
/datadog autotest review
@codex review
<!-- codex-review-receipt:v1 -->
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 93c3ccf8e2
<details> <summary>ℹ️ About Codex in GitHub</summary>
<br/>
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
</details>
<sub><sub>!P2 Badge</sub></sub> Normalize SSH remotes before comparing repository identities
When a GitHub Actions checkout uses an SSH remote and is remounted into a container at a different path from GITHUB_WORKSPACE, this comparison treats git@github.com:owner/repo.git and the provider's https://github.com/owner/repo.git as different repositories, even when the checkout SHA matches. Consequently, relatedCheckout becomes false and the resolver removes the PR number, head SHA, and base-branch metadata; detached checkouts also lose their CI branch fallback. This affects plugin-gate/src/commands/evaluate.ts, whose execute() only sets options.pull_request_sha when the retained base branch and head SHA exist. Normalize equivalent SSH and HTTPS repository identities before comparing them so a remounted checkout retains its PR association.
Useful? React with 👍 / 👎.
<!-- codex-code-review-finding:v1 -->
<!-- datadog-code-review reviewer-id=bad90057-5c12-4101-ad47-d91c9dff0f90 -->
<!-- datadog-autotest-inline:v1:prod -->
<!-- datadog-autotest-delivery:v1:prod:72bce1e73e14c9f4402a8b3768be6799044a58b55fa3afed31473c95ac3d4d4b:inline-0 -->
<sub><sub>!P1</sub></sub> Preserve PR metadata for Bitbucket merge checkouts
<!-- autotest-finding-meta prod_data_type=none finding_id=f1b01336-e443-4462-925d-c05dddb5ed72 prod_effect=static -->
In Bitbucket PR pipelines that merge the destination before building, HEAD is the generated merge commit while BITBUCKET_COMMIT names the source commit. The Bitbucket adapter supplies no merge revision, so this check rejects the checkout even when its root and remote match. A native-Git reproduction confirmed removal of pr.number and PR base fields, losing JUnit PR attribution and preventing coverage PR-diff generation. Recognize verified Bitbucket merge/source relationships while preserving the unrelated-revision guards.
<!-- datadog-autotest-feedback-legend:v1 -->
React: 👍 useful · 👎 wrong · 😕 unclear · 👀 right, but not acting on it
<details><summary>What each reaction means</summary>
</details>
<sub>🤖 Bits Code Review</sub> <sub>· <a href="https://app.datadoghq.com/code/988274a5-0e09-4888-acf4-05c9362bf367?referrer=autotest-pr-comment">Open Bits AI session</a></sub>
<!-- datadog-code-review reviewer-id=bad90057-5c12-4101-ad47-d91c9dff0f90 -->
<!-- datadog-autotest-inline:v1:prod -->
<!-- datadog-autotest-delivery:v1:prod:72bce1e73e14c9f4402a8b3768be6799044a58b55fa3afed31473c95ac3d4d4b:inline-1 -->
<sub><sub>!P2</sub></sub> Match equivalent SSH and HTTPS repository URLs
<!-- autotest-finding-meta prod_data_type=none finding_id=94c8f746-aff4-43b7-ad3e-e0f8f43c380c prod_effect=static -->
When a detached checkout is remounted at a different path, git@github.com:org/repo.git does not match CI's https://github.com/org/repo.git despite identifying the same repository and revision. A native-Git reproduction confirmed that this drops the CI branch, PR number, and PR-head/base metadata. Coverage consequently loses its PR diff, and gate evaluation omits its PR-head option. Normalize equivalent network remote forms before comparing them.
const remote = filterSensitiveInfoFromRepository(value)
const networkRemote = remote?.replace(/^git@([^/:]+):/, 'https://$1/').replace(/^ssh:\/\//, 'https://')
return networkRemote && /^https?:\/\//.test(networkRemote)
? networkRemote.replace(/(?:\.git)?\/?$/, '')
: networkRemote
<!-- datadog-autotest-feedback-legend:v1 -->
React: 👍 useful · 👎 wrong · 😕 unclear · 👀 right, but not acting on it
<details><summary>What each reaction means</summary>
</details>
<sub>🤖 Bits Code Review</sub> <sub>· <a href="https://app.datadoghq.com/code/988274a5-0e09-4888-acf4-05c9362bf367?referrer=autotest-pr-comment">Open Bits AI session</a></sub>
Valid CI checkouts can lose PR attribution and coverage diffs: Bitbucket-generated merge commits fail revision matching, and remounted checkouts with equivalent SSH/HTTPS remotes fail repository matching. Both cases reproduced with native Git.
<sub>Open Bits AI session</sub>
<sub>🤖 Bits Code Review · Commit 01b085c</sub>
<!-- autotest-meta model=gpt-6.1-sol engine=codex reasoning_effort=high verdict=FAIL ddrs_bucket=unknown session_id=988274a5-0e09-4888-acf4-05c9362bf367 -->
<!-- datadog-code-review reviewer-id=bad90057-5c12-4101-ad47-d91c9dff0f90 -->
<!-- datadog-autotest:v1:prod -->
<!-- datadog-autotest-delivery:v1:prod:72bce1e73e14c9f4402a8b3768be6799044a58b55fa3afed31473c95ac3d4d4b:bundle -->
<!-- datadog-code-review reviewer-id=bad90057-5c12-4101-ad47-d91c9dff0f90 -->
<!-- datadog-autotest-inline:v1:prod -->
<!-- datadog-autotest-delivery:v1:prod:ccda48721ddd53deb820caccdf9ec7a49075d9a0b1fec7fd6572e54cdc72b6d7:inline-0 -->
<sub><sub>!P2</sub></sub> Recognize equivalent SSH and HTTPS repository URLs
<!-- autotest-finding-meta prod_data_type=none finding_id=11cabb1f-51ac-452d-aeb5-1b6506212385 prod_effect=static -->
When a detached GitHub checkout with remote git@github.com:org/repo.git is remounted outside GITHUB_WORKSPACE, CI's equivalent HTTPS URL is rejected despite a matching SHA. Focused execution reproduced removal of the branch, PR head/base fields, and PR number. Coverage consequently loses PR-diff context, and gate evaluation stops setting pull_request_sha. Normalize equivalent SSH and HTTPS remotes so matching remounted checkouts retain their CI context.
const remote = filterSensitiveInfoFromRepository(value)
?.replace(/^git@([^/:]+):/, 'https://$1/')
.replace(/^ssh:\/\/([^/:]+)\//, 'https://$1/')
<!-- datadog-autotest-feedback-legend:v1 -->
React: 👍 useful · 👎 wrong · 😕 unclear · 👀 right, but not acting on it
<details><summary>What each reaction means</summary>
</details>
<sub>🤖 Bits Code Review</sub> <sub>· <a href="https://app.datadoghq.com/code/a70e31df-e787-4488-a0d9-13af2206ccf1?referrer=autotest-pr-comment">Open Bits AI session</a></sub>
A matching remounted SSH checkout is mistaken for an unrelated repository when CI supplies its equivalent HTTPS URL. This drops branch and pull-request metadata needed by coverage and gate evaluation.
<sub>Open Bits AI session</sub>
<sub>🤖 Bits Code Review · Commit 93c3ccf</sub>
<!-- autotest-meta model=gpt-6.1-sol engine=codex reasoning_effort=high verdict=FAIL ddrs_bucket=unknown session_id=a70e31df-e787-4488-a0d9-13af2206ccf1 -->
<!-- datadog-code-review reviewer-id=bad90057-5c12-4101-ad47-d91c9dff0f90 -->
<!-- datadog-autotest:v1:prod -->
<!-- datadog-autotest-delivery:v1:prod:ccda48721ddd53deb820caccdf9ec7a49075d9a0b1fec7fd6572e54cdc72b6d7:bundle -->
Fixed in 447de1b590a0d778a051be7f253ffd5673b5b964. Repository identity comparison now recognizes standard scp-style and ssh:// remotes as equivalent to the matching HTTPS repository, including default SSH port 22 and optional .git suffixes. Host/path, revision and unrelated-checkout guards remain in place; custom ports, aliases, tilde paths and ambiguous literal SSH paths are not guessed. Regressions verify the retained CI branch, PR number and head/base fields for remounted SSH checkouts, including native Git tests. The selected checkout SHA remains unchanged.
Fixed in 447de1b590a0d778a051be7f253ffd5673b5b964. Repository identity comparison now recognizes standard scp-style and ssh:// remotes as equivalent to the matching HTTPS repository, including default SSH port 22 and optional .git suffixes. Host/path, revision and unrelated-checkout guards remain in place; custom ports, aliases, tilde paths and ambiguous literal SSH paths are not guessed. Regressions verify the retained CI branch, PR number and head/base fields for remounted SSH checkouts, including native Git tests. The selected checkout SHA remains unchanged.
Fixed in 447de1b590a0d778a051be7f253ffd5673b5b964. For an otherwise mismatched Bitbucket PR checkout, the resolver now verifies a two-parent merge from the pinned local commit's raw headers, matching the CI source and any supplied destination revision. It retains PR context only after that verification and does not replace the actual checkout SHA with BITBUCKET_COMMIT. Tests cover remounts, absent parent objects, missing destination metadata, unrelated/non-merge commits, mismatched source/destination revisions and explicit overrides. Native scenarios pass on current Git and Git 2.30 with no ancestry walk. This follows Bitbucket's documented destination-into-source build setup.
Fixed in 447de1b590a0d778a051be7f253ffd5673b5b964. Repository identity comparison now recognizes standard scp-style and ssh:// remotes as equivalent to the matching HTTPS repository, including default SSH port 22 and optional .git suffixes. Host/path, revision and unrelated-checkout guards remain in place; custom ports, aliases, tilde paths and ambiguous literal SSH paths are not guessed. Regressions verify the retained CI branch, PR number and head/base fields for remounted SSH checkouts, including native Git tests. The selected checkout SHA remains unchanged.
/datadog autotest review
@codex review
<details>
<summary>More details</summary>
Git metadata follows explicit overrides, then the checkout, then CI fallback, while workflow context stays separate. Both earlier findings are fixed: verified Bitbucket merge checkouts retain PR metadata, and remounted checkouts match equivalent SSH/HTTPS remotes; no findings remain open.
</details>
Was this helpful? React 👍 or 👎
<sub>Open Bits AI session</sub>
<sub>🤖 Bits Code Review · Commit 447de1b</sub>
<!-- autotest-meta model=gpt-6.1-sol engine=codex reasoning_effort=high verdict=PASS ddrs_bucket=unknown session_id=988274a5-0e09-4888-acf4-05c9362bf367 -->
<!-- datadog-code-review reviewer-id=bad90057-5c12-4101-ad47-d91c9dff0f90 -->
<!-- datadog-autotest:v1:prod -->
<!-- datadog-autotest-delivery:v1:prod:4bc38e4cdfae79e8b1afd6c495629b26068a54da4934492429b8529eca66a063:bundle -->
<!-- codex-review-receipt:v1 -->
Codex Review: Didn't find any major issues. Chef's kiss.
Reviewed commit: 447de1b590
<details> <summary>ℹ️ About Codex in GitHub</summary>
<br/>
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
</details>
<!-- datadog-code-review reviewer-id=bad90057-5c12-4101-ad47-d91c9dff0f90 -->
<!-- datadog-autotest-inline:v1:prod -->
<!-- datadog-autotest-delivery:v1:prod:cff604a65fe6ca412536cd9222774694f448b07596dd0a27559126a2464263ce:inline-0 -->
<sub><sub>!P2</sub></sub> Initialize Git before resolving JUnit repository tags
<!-- autotest-finding-meta prod_data_type=none finding_id=b03c3b2a-5557-4da3-a91c-3edfdce55371 prod_effect=static -->
When a CI container runs in a custom checkout owned by another user, repository-tag resolution can fail Git's ownership check and cache the workflow repository URL. Only later does isGitRepo() configure safe.directory and make the checkout readable. The newly forwarded URL then overrides the checkout remote in uploadToGitDB(), uploading its commits under the workflow repository unless --git-repository-url is supplied. Initialize Git before resolving tags, as coverage already does.
await isGitRepo()
const repositoryTags = await getRepositoryTags(ciSpanTags)
<!-- datadog-autotest-feedback-legend:v1 -->
React: 👍 useful · 👎 wrong · 😕 unclear · 👀 right, but not acting on it
<details><summary>What each reaction means</summary>
</details>
<sub>🤖 Bits Code Review</sub> <sub>· <a href="https://app.datadoghq.com/code/e46eb66e-3f59-4af5-a366-292277bc1a3c?referrer=autotest-pr-comment">Open Bits AI session</a></sub>
For a checkout blocked by Git ownership checks, JUnit can retain the workflow repository URL after Git access is repaired, causing checkout commits to be uploaded under the wrong repository.
<sub>Open Bits AI session</sub>
<sub>🤖 Bits Code Review · Commit 447de1b</sub>
<!-- autotest-meta model=gpt-6.1-sol engine=codex reasoning_effort=high verdict=FAIL ddrs_bucket=unknown session_id=e46eb66e-3f59-4af5-a366-292277bc1a3c -->
<!-- datadog-code-review reviewer-id=bad90057-5c12-4101-ad47-d91c9dff0f90 -->
<!-- datadog-autotest:v1:prod -->
<!-- datadog-autotest-delivery:v1:prod:cff604a65fe6ca412536cd9222774694f448b07596dd0a27559126a2464263ce:bundle -->
/datadog autotest review
@codex review
The PR prioritizes checkout metadata and aligns Git uploads with the selected report SHA; Bitbucket merge and remounted SSH/HTTPS matching are fixed. One issue remains: the selected-tip fallback bypasses GitDB’s known-object pruning, repacking unchanged trees during normal incremental uploads.
<sub>Open Bits AI session</sub>
<sub>🤖 Bits Code Review · Commit c1545ca</sub>
<!-- autotest-meta model=gpt-6.1-sol engine=codex reasoning_effort=high verdict=FAIL ddrs_bucket=unknown session_id=988274a5-0e09-4888-acf4-05c9362bf367 -->
<!-- datadog-code-review reviewer-id=bad90057-5c12-4101-ad47-d91c9dff0f90 -->
<!-- datadog-autotest:v1:prod -->
<!-- datadog-autotest-delivery:v1:prod:cd5593043ba64a34a7524eb8a6ea3b52c2c5df83c6d048b12d2518903b853508:bundle -->
<!-- datadog-code-review reviewer-id=bad90057-5c12-4101-ad47-d91c9dff0f90 -->
<!-- datadog-autotest-inline:v1:prod -->
<!-- datadog-autotest-delivery:v1:prod:cd5593043ba64a34a7524eb8a6ea3b52c2c5df83c6d048b12d2518903b853508:inline-0 -->
<sub><sub>!P2</sub></sub> Preserve known-object pruning in the selected-tip fallback
<!-- autotest-finding-meta prod_data_type=none finding_id=2f965b79-fe45-4c83-bc54-850d67ae246c prod_effect=static -->
When GitDB knows the selected tip's parent but not the tip, getObjectsToUpload prunes unchanged trees. This fallback walks the tip without commitsToExclude and adds those trees back. JUnit and coverage now pass a SHA during ordinary uploads, so no override is needed to trigger this. A native-Git comparison on this checkout expanded the upload list from 16 objects to 292, increasing traversal, compression, memory, and upload costs. Only run the fallback when the first traversal omitted the selected commit, or preserve the known-commit exclusions.
if (commitSha && commitsToInclude.includes(commitSha) && !objectsToUpload.includes(commitSha)) {
<!-- datadog-autotest-feedback-legend:v1 -->
React: 👍 useful · 👎 wrong · 😕 unclear · 👀 right, but not acting on it
<details><summary>What each reaction means</summary>
</details>
<sub>🤖 Bits Code Review</sub> <sub>· <a href="https://app.datadoghq.com/code/988274a5-0e09-4888-acf4-05c9362bf367?referrer=autotest-pr-comment">Open Bits AI session</a></sub>
<!-- codex-review-receipt:v1 -->
Codex Review: Didn't find any major issues. Breezy!
Reviewed commit: c1545ca645
<details> <summary>ℹ️ About Codex in GitHub</summary>
<br/>
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
</details>
<!-- datadog-code-review reviewer-id=bad90057-5c12-4101-ad47-d91c9dff0f90 -->
<!-- datadog-autotest-inline:v1:prod -->
<!-- datadog-autotest-delivery:v1:prod:029ed641afd3722fb17339312b56701598c967e1072ebdd32a9b1c2ac3a9b7d0:inline-0 -->
<sub><sub>!P2</sub></sub> Honor repository mismatches when CI has no workspace path
<!-- autotest-finding-meta prod_data_type=none finding_id=6ba78d59-bfd7-4ba0-a807-af9c791a9877 prod_effect=static -->
Buddy does not populate ci.workspace_path, so !workspace bypasses a known repository-URL mismatch when a custom checkout shares the workflow commit SHA. A focused reproduction retained pr.number=42 and base branch workflow-main alongside a different checkout repository URL. Remove these unrelated relationships to avoid associating reports with another repository's PR.
const knownRepositoryMismatch =
!!checkout[GIT_REPOSITORY_URL] && !!provider[GIT_REPOSITORY_URL] && !matchingRepository
const relatedCheckout = !knownRepositoryMismatch && (!workspace || !root || matchingRepository) && matchingRevision
<!-- datadog-autotest-feedback-legend:v1 -->
React: 👍 useful · 👎 wrong · 😕 unclear · 👀 right, but not acting on it
<details><summary>What each reaction means</summary>
</details>
<sub>🤖 Bits Code Review</sub> <sub>· <a href="https://app.datadoghq.com/code/235d1314-4501-44b7-ae3b-bd4a5410ab67?referrer=autotest-pr-comment">Open Bits AI session</a></sub>
A checkout with a shared SHA can retain another repository’s PR relationships when CI omits its workspace path. The selected-tip fallback also expands incremental Git uploads by reintroducing unchanged trees.
<sub>Open Bits AI session</sub>
<sub>🤖 Bits Code Review · Commit c1545ca</sub>
<!-- autotest-meta model=gpt-6.1-sol engine=codex reasoning_effort=high verdict=FAIL ddrs_bucket=unknown session_id=235d1314-4501-44b7-ae3b-bd4a5410ab67 -->
<!-- datadog-code-review reviewer-id=bad90057-5c12-4101-ad47-d91c9dff0f90 -->
<!-- datadog-autotest:v1:prod -->
<!-- datadog-autotest-delivery:v1:prod:029ed641afd3722fb17339312b56701598c967e1072ebdd32a9b1c2ac3a9b7d0:bundle -->
/datadog autotest review
@codex review
<!-- codex-review-receipt:v1 -->
Codex Review: Didn't find any major issues. You're on a roll.
Reviewed commit: b101af38ec
<details> <summary>ℹ️ About Codex in GitHub</summary>
<br/>
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
</details>
Drarig29
juan-fernandez
What and why?
Report Git metadata for the checkout where the command runs. Previously, CI environment values could replace a custom checkout's SHA, branch and repository URL, while Git metadata upload read that custom checkout.
For example, this now reports
my-org/applicationand its checked-out revision rather than the workflow repository:How?
DD_GIT_*overrides, then the readable checkout as one source, then CI Git metadata when the checkout is unavailable. Keep CI workflow context andci.workspace_pathseparate.DD_GIT_COMMIT_SHA. Keep that SHA through commit discovery, shallow fetches and packfile declarations; unavailable selections never fall back toHEAD.ci.git.merge_commit_sha, normalize full SHAs, and preserveDD_CI_GIT_MERGE_COMMIT_SHAacross export/import without the original provider environment.Validation: build/lint, 337 CI-provider tests and 256 Git/report-upload tests pass. All 11 selected-commit regressions also pass with Git 2.30. Earlier full-suite validation had 23 failures identical to the unchanged control (16 missing
objcopy, seven reporter expectations).Review checklist