vondenstein / gatsby-plugin-git-lastmod

Gatsby plugin that generates lastmod values for your sitemap using git commit dates
MIT License
2 stars 0 forks source link

Error "gatsby-plugin-git-lastmod" threw an error while running the onCreatePage lifecycle (`continueWithoutRepo = true`) #12

Open Oleg-Fedorov-FO opened 1 month ago

Oleg-Fedorov-FO commented 1 month ago
image

We suddenly started facing this issue. We tried a solution from the previous discussion and added continueWithoutRepo = true to the plugin configuration. But it didn't help

The build is not failing locally and in Bitbucket pipelines. This error occurs only in Netlify deployment process

Any ideas? @vondenstein

vondenstein commented 1 month ago

Thanks for reaching out @Oleg-Fedorov-FO!

I have not encountered this before, but it looks like git itself is having trouble pulling data from your repository. The "Host key verification failed" is likely due to the build server not recognizing the public key of the remote git server.

I believe that the reason this is only happening in the Netlify deployment process is because Netlify uses "blobless clones", which means that some data will be fetched on-demand. For some reason, git is failing due to "Host key verification failed." when it tries to fetch that data.

Could you try setting the environment variable GIT_SSH_COMMAND to ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no within your Netlify build and see if that solves the issue? If not, could you try disabling the plugin to determine whether this issue only occurs with the plugin enabled?

Oleg-Fedorov-FO commented 1 month ago

Thanks @vondenstein!

Unfortunately adding GIT_SSH_COMMAND didn't help.

Disabling the plugin helps, so the issue only occurs with the plugin enabled

Here is the error we got with continueWithoutRepo = true and GIT_SSH_COMMAND added

image
vondenstein commented 1 month ago

It looks like git is unable to connect to the Bitbucket repository over ssh due to an issue with the ssh key. Just to make sure, have you configured the SSH key within Bitbucket and Netlify so that git is able to access the ssh key inside the Netlify deploy?

If yes, then I'm a little unsure what could be causing the error. Does your repository contain any git submodules or use git lfs? It seems that Netlify can have issues when using either of those.

If not, I think we need to get some more information about how the plugin is failing in order to solve this issue. Could you try setting NETLIFY_BUILD_DEBUG variable to true, and see if this gives more information when the error is thrown? It may also help to clear the Netlify build cache before trying this. Also, is the command used to build locally and in the pipeline (which is confirmed to work) the same as the command used to build in the Netlify deploy?

It would also help to know what file it is failing on, mainly the type and size of the file (and the filename if you are comfortable sharing). Could you please try running git describe --always 091d25e21017b19da6b0a74f3aabc1e76636fa22 locally? This should give us the file associated with the blob in your error log. Or if that doesn't work, git log --raw --all --find-object=091d25e21017b19da6b0a74f3aabc1e76636fa22 should also give the filename.

Until this is solved, can you use the Bitbucket pipeline to deploy? It looks like it should be possible to deploy using the Netlify CLI from a pipeline.