I am building a blog and wanted to add a build step to notify when a new post is added. The script checks for any posts added between VERCEL_GIT_PREVIOUS_SHA and the building commit.
const currentSha = env.VERCEL_GIT_COMMIT_SHA;
const previousSha = env.VERCEL_GIT_PREVIOUS_SHA;
if (!currentSha || !previousSha) {
log(`skip: missing SHA (current=${currentSha ?? "unset"}, previous=${previousSha ?? "unset"})`);
process.exit(0);
}
Unfortunately, even on the main branch that has been deployed multiple times this fails:
[notify-on-publish] skip: missing SHA (current=360751584f5a2db35960b8d9c32770e5b14f17ee, previous=)
example deploy: https://vercel.com/discorevs-projects/sanedev/8HUHcS52C3UVfgtsmapb6mxAQUJQ
The help AI was helpful, until it wasn’t:
I can see the issue now. Looking at your deployment history for the main branch, I can confirm there are multiple successful production deployments. Let me check one more thing about the project configuration:
I can see that your project has autoExposeSystemEnvs: true, which means system environment variables should be exposed. You also have multiple successful production deployments on the main branch.
This appears to be a bug or unexpected behavior with how VERCEL_GIT_PREVIOUS_SHA is being populated. Based on your deployment history, there are clearly previous successful deployments on main that should be providing the previous SHA.
What I found:
* Your latest deployment (360751584f...) should have referenced the previous deployment (b6a2dcd2a9...) as the previous SHA
* System environment variables are correctly enabled (autoExposeSystemEnvs: true)
* All your recent main deployments are from Git pushes (not redeployments), so the Git context should be available
This looks like it may be a platform issue rather than a configuration problem on your end. Let me check if you're eligible to create a support case so our team can investigate why VERCEL_GIT_PREVIOUS_SHA isn't being populated correctly for your project.
Good news — you're eligible to create a support case for this. This does appear to be unexpected behavior that our team should investigate further.
Summary of the issue:
* VERCEL_GIT_PREVIOUS_SHA is empty on main branch deployments despite multiple previous successful deployments existing
* System environment variables are enabled
* Deployments are triggered via Git (not manual redeployments)
* The variable should be populated but isn't
On the hobby plan you are not eligible to create a support case. (the AI being wrong is a separate issue, it’s just included to show that the issue was also triaged by the AI which agrees it’s a support issue).