Skip to content

fix(website/ci): build when the previous Vercel commit is unavailable - #832

Merged
ajitpratap0 merged 1 commit into
mainfrom
fix/vercel-ignore-missing-sha
Oct 21, 2026
Merged

ajitpratap0 merged 1 commit into
mainfrom
fix/vercel-ignore-missing-sha

Conversation

@ajitpratap0

Copy link
Copy Markdown
Owner

Description

website/scripts/vercel-ignore.sh (added in #821) runs git diff $VERCEL_GIT_PREVIOUS_SHA HEAD. When a PR branch is force-pushed (a rebase, for example), the previously deployed commit is no longer in Vercel's clone:

  • git diff exits 128 with fatal: bad object <sha>.
  • Vercel fails the deployment for any exit code other than 0 (skip) or 1 (build).
  • The Vercel check therefore goes red for reasons unrelated to the code.

Observed on #825, #827 and #828 after rebasing them onto main. Deployment dpl_8HzjNoKTPk5VJkkKRZW8AgUMyLyx log: fatal: bad object 5b5aa61e….

Changes Made

  • If the previous commit cannot be resolved (git cat-file -e), build (exit 1).
  • Every non-skip outcome now exits 1, so the script can no longer fail a deployment.
  • Logs why a preview was skipped.
  • Production and [vercel skip] behaviour are unchanged.

Type of Change

  • Bug fix (non-breaking)

Testing

Exercised every path in a scratch git repo:

Case Exit code Expected
production 1 1
[vercel skip] 0 0
no site change (via HEAD^) 0 0
missing previous SHA 1 1 (previously 128)
site change 1 1
root commit with no HEAD^ 1 1

bash -n passes.

Breaking Changes

None.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KTj1PEbxzVCETkeYrZKcrE

vercel-ignore.sh ran git diff against VERCEL_GIT_PREVIOUS_SHA. After a
force-push that commit no longer exists in Vercel's clone, git diff
exits 128 ("fatal: bad object"), and Vercel fails the deployment for
any exit code other than 0/1. Build when the previous commit cannot be
resolved, and map every non-skip outcome to exit 1.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KTj1PEbxzVCETkeYrZKcrE
@vercel

vercel Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
gosqlx-website Ready Ready Preview Oct 20, 2026 7:30am UTC

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Claude finished @ajitpratap0's task in 21s —— View job


Review of PR #832

  • Read website/scripts/vercel-ignore.sh
  • Analyze the exit-code paths

Verdict: LGTM. The fix is correct, small, and targeted.

What I checked

  • Root cause fixed. git cat-file -e "${prev}^{commit}" is the right way to test that the commit object exists. It avoids the exit 128 from git diff on a missing object. The ^{commit} peel also handles the HEAD^ fallback.
  • No path can fail the deployment now. The only exit codes are 0 and 1. if git diff --quiet … is true only on exit 0 (no diff). Exit 1 (diff) and 128 (any other git error) both fall through to exit 1, so unexpected errors fail safe toward building.
  • Behaviour unchanged for production and [vercel skip]. Both still behave as before. The new log lines make skip and build decisions visible in the Vercel logs.
  • Security. All variables are quoted. $VERCEL_GIT_COMMIT_MESSAGE is only matched in a case and never evaluated. A $prev that starts with - can't be interpreted as an option by cat-file in practice, because it is suffixed with ^{commit} and the SHA is Vercel-provided.

Minor, non-blocking suggestions

  1. git diff "$prev" HEAD would be slightly safer written as git diff --quiet "$prev" HEAD --, with an explicit -- before the pathspecs. You already have -- . there, so this is fine as is.
  2. Consider echoing a "Preview building: changes detected" line before the final exit 1. That would make every outcome visible in the logs.
  3. Test coverage: the scratch-repo table in the description is good. If you want regression protection, a small shell test script could live next to this one, but that is optional for a 25-line script.

No bugs found.

@ajitpratap0
ajitpratap0 merged commit c71fca1 into main Oct 21, 2026
32 checks passed

This branch was successfully deployed

1 active deployment
Preview — 21f26a02 Deployed Oct 20, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant