Skip to content

fix(core): guard against empty release in graduation check - #2531

Merged
sugarmanz merged 1 commit into
mainfrom
fix/safe-graduation-check
Jun 18, 2026
Merged

sugarmanz merged 1 commit into
mainfrom
fix/safe-graduation-check

Conversation

@sugarmanz

@sugarmanz sugarmanz commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

Backport of the graduation-check guard from player-ui/player#885, applied to the TypeScript source (this repo is the source of @auto-it/core).

Problem

auto shipit --only-graduate-with-release-label threw TypeError: Cannot read properties of undefined (reading 'labels') when the release contained no commits — head[0] is undefined and .labels blows up.

Fix

Guard the access with head.length > 0 before reading head[0].labels, so an empty release simply does not graduate.

Test

Added a regression test in packages/core/src/__tests__/auto.test.ts ("should not graduate with an empty release when onlyGraduateWithReleaseLabel is set") that mocks an empty getCommitsInRelease, asserts shipit resolves without throwing, and that latest() is not called. Verified it fails without the guard and passes with it.

🐤 Download canary assets:

auto-linux--canary.2531.2745a1a9810aac04cbd5119d35906eee96783e72.gz
auto-macos--canary.2531.2745a1a9810aac04cbd5119d35906eee96783e72.gz
auto-win.exe--canary.2531.2745a1a9810aac04cbd5119d35906eee96783e72.gz

shipit threw "Cannot read properties of undefined (reading 'labels')"
when --only-graduate-with-release-label was set and the release had no
commits (head[0] is undefined). Guard the access with head.length > 0
so an empty release simply does not graduate.
@sugarmanz sugarmanz added the patch Increment the patch version when merged label Jun 17, 2026
@sugarmanz
sugarmanz merged commit fc18021 into main Jun 18, 2026
12 of 14 checks passed
@sugarmanz
sugarmanz deleted the fix/safe-graduation-check branch June 18, 2026 05:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch Increment the patch version when merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant