Skip to content

[ML] Make changelog validation robust to shallow-clone merge base#3119

Merged
edsavage merged 1 commit into
elastic:mainfrom
edsavage:fix/changelog-validate-merge-base
Jul 27, 2026
Merged

[ML] Make changelog validation robust to shallow-clone merge base#3119
edsavage merged 1 commit into
elastic:mainfrom
edsavage:fix/changelog-validate-merge-base

Conversation

@edsavage

Copy link
Copy Markdown
Contributor

Summary

The Validate changelog entries step (.buildkite/scripts/steps/validate-changelogs.sh) fetches the PR base with --depth=1 and then runs a three-dot diff:

git diff --name-only --diff-filter=ACM origin/<base>...HEAD -- 'docs/changelog/*.yaml'

When a PR branched from an older point of the base branch, the shallow (--depth=1) histories share no common ancestor, so git aborts with:

fatal: origin/main...HEAD: no merge base

(exit 128). The diff runs inside a command substitution under set -euo pipefail, so the script dies at that line — before its own DIFF_EXIT/"skipping" soft-handler could run. The handler was effectively dead code, and the step hard-failed.

This is latent for any sufficiently-diverged branch; it surfaced on #3078 (see build 2895).

Fix

  • Guard the diff with if ! VAR=$(...), which suppresses set -e for that command (the previous $? inspection could never be reached).
  • On failure, progressively deepen both histories (--deepen 50/250/1000) to recover a merge base and retry.
  • Only if that still fails, soft-skip with a warning.

This matters now that the overall build status (buildkite/ml-cpp-pr-builds) is a required check on main: a CI clone-depth limitation must never hard-fail an otherwise valid PR. Valid changelogs are still fully validated whenever a merge base is available (the common case, and now the deepened case).

Test plan

The validate-changelogs step fetches the PR base with --depth=1 and then
runs a three-dot diff (origin/<base>...HEAD). When a PR branched from an
older commit, the shallow histories share no common ancestor and git aborts
with 'fatal: origin/main...HEAD: no merge base' (exit 128). As the diff runs
in a command substitution under 'set -e', the script died before its own
DIFF_EXIT soft-skip handler could run, hard-failing the step.

Guard the diff with 'if' (suppressing set -e), progressively deepen both
histories to recover a merge base and retry, and only soft-skip as a last
resort. This matters now that the overall build status is a required check:
a CI clone-depth limitation must not block an otherwise valid PR.

Co-authored-by: Cursor <cursoragent@cursor.com>
@elasticsearchmachine

Copy link
Copy Markdown

Pinging @elastic/ml-core (Team:ML)

@edsavage
edsavage merged commit c3e922b into elastic:main Jul 27, 2026
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants