Skip to content

fix: push release branches with git CLI - #17397

Merged
fr4nc1sc0-r4m0n merged 8 commits into
mainfrom
fix-release-push-git-cli
Nov 18, 2026
Merged

fr4nc1sc0-r4m0n merged 8 commits into
mainfrom
fix-release-push-git-cli

Conversation

@fr4nc1sc0-r4m0n

@fr4nc1sc0-r4m0n fr4nc1sc0-r4m0n commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Motivation

Build #24 of elastic-agent-version-bump got past the SSH/GITHUB_TOKEN auth mismatch from #17385, then hung for the rest of the job timeout on the first push of the new 9.6 branch. The checkout is a Buildkite --reference clone; go-git can read alternates after #17358 but its Push path never returns. Version bumps still cannot publish release branches or open PRs.

Ingest-release-smoke build 8 then showed that Authorization: Bearer on git HTTPS is rejected for Vault/App tokens (remote: invalid credentials). The smoke harness already uses Basic x-access-token.

Summary

  • Replace go-git Push with native git push so reference clones can pack and upload.
  • Authenticate with http.extraHeader=Authorization: Basic for x-access-token:<token> (not Bearer).
  • Keep SSH→HTTPS remote rewrite before push.
  • Bound the push with a 10-minute timeout and log before/after so hangs are visible.
  • Allow file:// remotes for local unit tests; add a local bare-remote push test.
  • Point pre-merge docs at observability-robots ingest-release-smoke.

Related issues

Risk

  • Low: isolated change, no effect on Fleet connectivity, policy handling, or upgrades

Rationale

Native git already understands alternate object stores from reference clones (same reason SyncSubmodules shells out). Token auth stays on an HTTP header so the secret is not written into the remote URL. Basic x-access-token matches GitHub git-over-HTTPS and the ingest-release-smoke harness.

Rollout and safety

N/A — release tooling only; does not change the agent runtime or Fleet path.

Testing

  • go test ./dev-tools/mage/release/ -count=1 -run 'TestPush|TestEnsureHTTPS|TestGithubHTTPS|TestGitHTTPSAuth' — passed
  • Validated end-to-end on ingest-release-smoke build 9 (SOURCE_SHA=d3b61c62): major-minor and patch both completed; all git CLI pushes succeeded (9.6, ff-prep-main-9.6.0, ff-release-9.6.0, ff-prep-next-patch-9.6.1, patch-release-9.6.0) with no invalid credentials
  • After merge, re-run elastic-agent-version-bump and confirm the same push logs without hanging

Validations

Local fork re-run of mage release:runMajorMinor / mage release:runPatch against fr4nc1sc0-r4m0n/elastic-agent (this PR branch, including git-CLI push).

Minor releases

runMajorMinor opens PR-A (main: next minor + mergify + docs/manifests) and PR-B (release branch ff-release). Next-patch bumps are not opened here; use mage release:runPatch.

Current (grouped) Former (elastic/elastic-agent) Role Status
fr4nc1sc0-r4m0n#43 #15424 + #15425 PR-A: next minor on main + backport rule + docs/manifests ✅ re-run 9.7.0
fr4nc1sc0-r4m0n#44 — (release branch content was not opened as a former bot PR) PR-B: ff-release on release branch ✅

Patch releases

This branch still uses the pre–ingest-dev#10200 patch shape: docs before build, then next-patch version after release. (#17835 aligns patch to a single bump PR.)

Current (grouped) Former (elastic/elastic-agent) Role Status
fr4nc1sc0-r4m0n#45 #15000 PR-A: docs/manifests for CURRENT_RELEASE ✅ re-run 9.4.10
fr4nc1sc0-r4m0n#46 #14423 PR-B: next patch on release branch ✅

@fr4nc1sc0-r4m0n
fr4nc1sc0-r4m0n requested a review from a team as a code owner October 21, 2026 16:38
@fr4nc1sc0-r4m0n fr4nc1sc0-r4m0n added bug Something isn't working Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team skip-changelog backport-active-all Automated backport with mergify to all the active branches labels Oct 21, 2026
@fr4nc1sc0-r4m0n fr4nc1sc0-r4m0n self-assigned this Oct 21, 2026
@infra-vault-gh-plugin-prod

Copy link
Copy Markdown

Pinging @elastic/elastic-agent-control-plane (Team:Elastic-Agent-Control-Plane)

@github-actions

Copy link
Copy Markdown
Contributor

TL;DR

golangci-lint failed in all six matrix jobs on the same new finding: gosec rule G204 at dev-tools/mage/release/git.go:375 (exec.CommandContext in Push). Immediate action: add a justified suppression (or equivalent hardening that satisfies gosec) for this controlled git invocation, then re-run lint.

Remediation

  • Add a targeted gosec suppression on the exec.CommandContext call in Push (for example (nolint/redacted):gosec or // #nosec G204) with a clear justification that command binary is fixed (git) and arguments are release-automation-controlled (remoteName, computed refSpec, token header).
  • Keep the call semantics unchanged (timeout + combined output handling), run mage check:lint, and confirm the golangci-lint workflow passes on re-run.
Investigation details

Root Cause

The PR switched Push from go-git to native CLI (exec.CommandContext). gosec flags this pattern as G204 (subprocess with potentially tainted input). Because this is a new issue in changed code, only-new-issues fails every matrix job.

Evidence

##[error]dev-tools/mage/release/git.go:375:9: G204: Subprocess launched with a potential tainted input or cmd arguments (gosec)
* gosec: 1
##[error]issues found
  • Reproduced across all failed jobs:
    • lint (ubuntu-latest, default)
    • lint (ubuntu-latest, define)
    • lint (windows-latest, default)
    • lint (windows-latest, define)
    • lint (macos-latest, default)
    • lint (macos-latest, define)

Validation

  • Local tests/commands in this investigation: not run (analysis based on workflow run logs).

Follow-up

  • I checked prior PR comments and did not find an earlier PR Actions Detective report for this same failure on this PR.

What is this? | From workflow: PR Actions Detective

Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not.

@github-actions github-actions Bot mentioned this pull request Oct 21, 2026

@ebeahan ebeahan left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The linters are all returning the same error:

  Error: dev-tools/mage/release/git.go:375:9: G204: Subprocess launched with a potential tainted input or cmd arguments (gosec)
  	cmd := exec.CommandContext(ctx, "git",
  		"-c", "http.extraHeader=Authorization: Bearer "+token,
  		"push", remoteName, refSpec,
  	)
  1 issues:
  * gosec: 1

can this be addressed?

@fr4nc1sc0-r4m0n
fr4nc1sc0-r4m0n marked this pull request as draft October 28, 2026 09:59
@github-actions

This comment has been minimized.

mallendem
mallendem previously approved these changes Nov 6, 2026
Comment thread dev-tools/mage/release/git.go Resolved
Comment thread dev-tools/mage/release/git.go Resolved
Comment thread dev-tools/mage/release/git.go Resolved
Comment thread dev-tools/mage/release/git.go Resolved
Comment thread dev-tools/mage/release/git.go Resolved
Comment thread dev-tools/mage/release/git.go Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

A hung Git helper or pre-push hook can keep CombinedOutput blocked beyond the ten-minute deadline because output draining is unbounded, requiring a nonzero WaitDelay and a regression test.

1 open issue
What changed in this PR

This PR switches release-tooling pushes from go-git to native Git to address hangs in Buildkite reference clones. It affects release automation, not the Elastic Agent runtime.

Changes:

  • Uses native git push with Basic token authentication, a ten-minute context deadline, and progress logging.
  • Adds authentication and local bare-remote push tests, plus pre-merge smoke-test instructions.
  • Standardizes release commit messages and PR text to [Release][version].
File Description
dev-tools/​mage/​release/​workflows.go Standardizes release commit messages, PR titles, and body headings.
dev-tools/​mage/​release/​README.md Documents pre-merge release smoke testing.
dev-tools/​mage/​release/​github_test.go Updates test PR titles to the new format.
dev-tools/​mage/​release/​git.go Replaces go-git pushes with native Git and process-local token authentication.
dev-tools/​mage/​release/​git_test.go Adds authentication, remote restriction, and local push coverage.

Review effort: Balanced

Comment thread dev-tools/mage/release/git.go Resolved
@mergify

mergify Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

This pull request is merged.

@swiatekm swiatekm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, but we should make the tests use testify for assertions.

Comment thread dev-tools/mage/release/git_test.go Resolved
GitHub git-over-HTTPS rejects Bearer for Vault/App tokens. Match
ingest-release-smoke Basic x-access-token; cite smoke build 8.
Fixed git binary; remote and refSpec come from local repo state.
Token is only passed in the Basic auth header.
Avoid gosec G204 without nolint by keeping argv literal
(git push origin HEAD) and injecting Basic auth through
GIT_CONFIG_* instead of http.extraHeader on the command line.
Align generated bump PR titles with a shared [Release][<version>]
prefix so feature-freeze PRs are easy to group.
Bound CombinedOutput with WaitDelay after context cancel, clear
conflicting github.com extraHeaders before setting Basic auth, and
disable interactive git prompts.
Align the release mage package tests with the repo preference for require/assert.
@fr4nc1sc0-r4m0n
fr4nc1sc0-r4m0n force-pushed the fix-release-push-git-cli branch from 6485101 to acbdc69 Compare November 17, 2026 19:35
@fr4nc1sc0-r4m0n
fr4nc1sc0-r4m0n enabled auto-merge (squash) November 18, 2026 11:18
@fr4nc1sc0-r4m0n
fr4nc1sc0-r4m0n merged commit 0c2f24f into main Nov 18, 2026
43 checks passed
@fr4nc1sc0-r4m0n
fr4nc1sc0-r4m0n deleted the fix-release-push-git-cli branch November 18, 2026 17:01
@github-actions

Copy link
Copy Markdown
Contributor

@Mergifyio backport 9.6 9.5 9.4 8.19

@mergify

mergify Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

backport 9.6 9.5 9.4 8.19

✅ Backports have been created

Details

fr4nc1sc0-r4m0n added a commit that referenced this pull request Nov 18, 2026
* fix: push release branches with git CLI

go-git Push hangs on Buildkite reference clones after HTTPS auth
is fixed. Use native git with a Bearer token and a push timeout.

* docs: point release mage authors at playground smoke

Document how to run the Buildkite release smoke before merging
changes under dev-tools/mage/release. DRY_RUN alone is not enough.

* fix: use Basic auth for git CLI release pushes

GitHub git-over-HTTPS rejects Bearer for Vault/App tokens. Match
ingest-release-smoke Basic x-access-token; cite smoke build 8.

* fix: silence gosec G204 on release git CLI push

Fixed git binary; remote and refSpec come from local repo state.
Token is only passed in the Basic auth header.

* fix: pass git push auth via GIT_CONFIG env

Avoid gosec G204 without nolint by keeping argv literal
(git push origin HEAD) and injecting Basic auth through
GIT_CONFIG_* instead of http.extraHeader on the command line.

* release: use [Release][version] PR title prefix

Align generated bump PR titles with a shared [Release][<version>]
prefix so feature-freeze PRs are easy to group.

* fix: harden release git push timeout and auth env

Bound CombinedOutput with WaitDelay after context cancel, clear
conflicting github.com extraHeaders before setting Basic auth, and
disable interactive git prompts.

* test: use testify in mage release package tests

Align the release mage package tests with the repo preference for require/assert.

(cherry picked from commit 0c2f24f)

Co-authored-by: Francisco Ramon <francisco.ramon@elastic.co>
fr4nc1sc0-r4m0n added a commit that referenced this pull request Nov 18, 2026
* fix: push release branches with git CLI

go-git Push hangs on Buildkite reference clones after HTTPS auth
is fixed. Use native git with a Bearer token and a push timeout.

* docs: point release mage authors at playground smoke

Document how to run the Buildkite release smoke before merging
changes under dev-tools/mage/release. DRY_RUN alone is not enough.

* fix: use Basic auth for git CLI release pushes

GitHub git-over-HTTPS rejects Bearer for Vault/App tokens. Match
ingest-release-smoke Basic x-access-token; cite smoke build 8.

* fix: silence gosec G204 on release git CLI push

Fixed git binary; remote and refSpec come from local repo state.
Token is only passed in the Basic auth header.

* fix: pass git push auth via GIT_CONFIG env

Avoid gosec G204 without nolint by keeping argv literal
(git push origin HEAD) and injecting Basic auth through
GIT_CONFIG_* instead of http.extraHeader on the command line.

* release: use [Release][version] PR title prefix

Align generated bump PR titles with a shared [Release][<version>]
prefix so feature-freeze PRs are easy to group.

* fix: harden release git push timeout and auth env

Bound CombinedOutput with WaitDelay after context cancel, clear
conflicting github.com extraHeaders before setting Basic auth, and
disable interactive git prompts.

* test: use testify in mage release package tests

Align the release mage package tests with the repo preference for require/assert.

(cherry picked from commit 0c2f24f)

Co-authored-by: Francisco Ramon <francisco.ramon@elastic.co>
fr4nc1sc0-r4m0n added a commit that referenced this pull request Nov 18, 2026
* fix: push release branches with git CLI

go-git Push hangs on Buildkite reference clones after HTTPS auth
is fixed. Use native git with a Bearer token and a push timeout.

* docs: point release mage authors at playground smoke

Document how to run the Buildkite release smoke before merging
changes under dev-tools/mage/release. DRY_RUN alone is not enough.

* fix: use Basic auth for git CLI release pushes

GitHub git-over-HTTPS rejects Bearer for Vault/App tokens. Match
ingest-release-smoke Basic x-access-token; cite smoke build 8.

* fix: silence gosec G204 on release git CLI push

Fixed git binary; remote and refSpec come from local repo state.
Token is only passed in the Basic auth header.

* fix: pass git push auth via GIT_CONFIG env

Avoid gosec G204 without nolint by keeping argv literal
(git push origin HEAD) and injecting Basic auth through
GIT_CONFIG_* instead of http.extraHeader on the command line.

* release: use [Release][version] PR title prefix

Align generated bump PR titles with a shared [Release][<version>]
prefix so feature-freeze PRs are easy to group.

* fix: harden release git push timeout and auth env

Bound CombinedOutput with WaitDelay after context cancel, clear
conflicting github.com extraHeaders before setting Basic auth, and
disable interactive git prompts.

* test: use testify in mage release package tests

Align the release mage package tests with the repo preference for require/assert.

(cherry picked from commit 0c2f24f)

Co-authored-by: Francisco Ramon <francisco.ramon@elastic.co>
fr4nc1sc0-r4m0n added a commit that referenced this pull request Nov 19, 2026
* fix: push release branches with git CLI

go-git Push hangs on Buildkite reference clones after HTTPS auth
is fixed. Use native git with a Bearer token and a push timeout.

* docs: point release mage authors at playground smoke

Document how to run the Buildkite release smoke before merging
changes under dev-tools/mage/release. DRY_RUN alone is not enough.

* fix: use Basic auth for git CLI release pushes

GitHub git-over-HTTPS rejects Bearer for Vault/App tokens. Match
ingest-release-smoke Basic x-access-token; cite smoke build 8.

* fix: silence gosec G204 on release git CLI push

Fixed git binary; remote and refSpec come from local repo state.
Token is only passed in the Basic auth header.

* fix: pass git push auth via GIT_CONFIG env

Avoid gosec G204 without nolint by keeping argv literal
(git push origin HEAD) and injecting Basic auth through
GIT_CONFIG_* instead of http.extraHeader on the command line.

* release: use [Release][version] PR title prefix

Align generated bump PR titles with a shared [Release][<version>]
prefix so feature-freeze PRs are easy to group.

* fix: harden release git push timeout and auth env

Bound CombinedOutput with WaitDelay after context cancel, clear
conflicting github.com extraHeaders before setting Basic auth, and
disable interactive git prompts.

* test: use testify in mage release package tests

Align the release mage package tests with the repo preference for require/assert.

(cherry picked from commit 0c2f24f)

Co-authored-by: Francisco Ramon <francisco.ramon@elastic.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-active-all Automated backport with mergify to all the active branches bug Something isn't working skip-changelog Team:Elastic-Agent-Control-Plane Label for the Agent Control Plane team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants