Skip to content

validate and audit default range misses commits and fails on young repositories' pull requests #409

Closed

Description

@stackbilt-admin

Problem

With no --range, charter validate and charter audit use getRecentCommitRange() (packages/cli/src/git-helpers.ts:139 on main), which returns HEAD~min(5, count-1)..HEAD. The generated CI workflow passes no range, which causes two problems.

1. Commits older than the window aren't checked

A pull request with more than five commits has its earlier commits outside the window, so an untrailered commit there passes the gate that the docs describe as checking "all commits".

2. Young repositories fail on pull requests

GitHub checks out a synthetic merge commit. count includes the branch's commits, but HEAD~N walks first parents, which is only the base branch's history. With few commits on main, that revision doesn't exist.

Reproduced on 2.1.0 by an independent reviewer, in a clone with a simulated PR merge commit, on Windows and WSL Ubuntu with Node 24.19.0:

fatal: ambiguous argument 'HEAD~2..HEAD'

Exit 2. The same run with an explicit --range "$BASE_SHA..$HEAD_SHA" exited 0.

The window also includes the synthetic merge commit itself, which carries no trailer.

Expected

The generated workflow should pass an explicit range. This works in our project on GitHub Actions, using a head-SHA range so the synthetic merge commit is excluded:

env:
  BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.before }}
  HEAD_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
run: pnpm exec charter validate --ci --format text --range "$BASE_SHA..$HEAD_SHA"

The CLI's default could also check that the revision exists, and report a clear error if not.

Also worth considering

Merge commits created by GitHub's merge button have no trailer, so a repository using them fails validate on the push to main. We chose rebase-only merging. The docs could mention this.

Scope

The fatal error was reproduced with simulated commits. Our project's real pull request passes on GitHub with the explicit range. I did not run the unmodified generated workflow on GitHub.

Activity

  1. added
    bug
    priority:p1
    on Oct 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugpriority:p1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions