Netlify github app to git organization - Permission denied (publickey)

Site name : scoring-staging.netlify.app
Site id : 3d802951-eee1-41ea-88cc-2b5eef7a86a5

FULL build log:

9:07:19 AM: build-image version: ecdc8b770f4a0193fd3f258c1bc6029e681813a4 (focal)
9:07:19 AM: buildbot version: 22552e71c3c7b6a5ebfd780eb1c9b2f42fe63aa7
9:07:19 AM: Fetching cached dependencies
9:07:19 AM: Failed to fetch cache, continuing with build
9:07:19 AM: Starting to prepare the repo for build
9:07:20 AM: No cached dependencies found. Cloning fresh repo
9:07:20 AM: git clone --filter=blob:none https://github.com/SCORING-FIT/leaderboard_front
9:07:20 AM: Preparing Git Reference refs/heads/staging
9:07:23 AM: Starting to install dependencies
9:07:23 AM: Python version set to 3.8
9:07:23 AM: Attempting Ruby version 2.7.2, read from environment
9:07:24 AM: Using Ruby version 2.7.2
9:07:25 AM: Started restoring cached go cache
9:07:25 AM: Finished restoring cached go cache
9:07:26 AM: go version go1.19.13 linux/amd64
9:07:27 AM: Using PHP version 8.0
9:07:29 AM: Downloading and installing node v16.20.2...
9:07:29 AM: Downloading https://nodejs.org/dist/v16.20.2/node-v16.20.2-linux-x64.tar.xz...
9:07:29 AM: Computing checksum with sha256sum
9:07:29 AM: Checksums matched!
9:07:31 AM: Now using node v16.20.2 (npm v8.19.4)
9:07:31 AM: Enabling Node.js Corepack
9:07:31 AM: Started restoring cached build plugins
9:07:31 AM: Finished restoring cached build plugins
9:07:31 AM: Started restoring cached corepack dependencies
9:07:31 AM: Finished restoring cached corepack dependencies
9:07:31 AM: No npm workspaces detected
9:07:31 AM: Started restoring cached node modules
9:07:31 AM: Finished restoring cached node modules
9:07:32 AM: Installing npm packages using npm version 8.19.4
9:07:59 AM: Failed during stage 'Install dependencies': dependency_installation script returned non-zero exit code: 1
9:07:59 AM: npm ERR! code 128
9:07:59 AM: npm ERR! An unknown git error occurred
9:07:59 AM: npm ERR! command git --no-replace-objects ls-remote ssh://git@github.com/securedeveloper/js-xlsx.git
9:07:59 AM: npm ERR! Warning: Permanently added 'github.com,140.82.112.4' (ECDSA) to the list of known hosts.
9:07:59 AM: npm ERR! git@github.com: Permission denied (publickey).
9:07:59 AM: npm ERR! fatal: Could not read from remote repository.
9:07:59 AM: npm ERR!
9:07:59 AM: npm ERR! Please make sure you have the correct access rights
9:07:59 AM: npm ERR! and the repository exists.
9:07:59 AM: npm ERR! A complete log of this run can be found in:
9:07:59 AM: npm ERR!     /opt/buildhome/.npm/_logs/2024-08-01T08_07_32_253Z-debug-0.log
9:07:59 AM: Error during npm install
9:07:59 AM: Failing build: Failed to install dependencies
9:08:00 AM: Finished processing build request in 40.525s

Build settings:

Runtime: Not set
Base directory: /
Package directory: Not set
Build command: npm run build
Publish directory: build
Functions directory: netlify/functions
Build status: Active

I tried asking the generative AI chatbot:

Error code 128 usually indicates a problem with cloning your repository. This typically means that Netlify doesn't have permission to clone the repository you're trying to deploy. This can happen if someone made changes to the settings for the parent organization or repository after linking the repository to your site.

To fix this, you can try relinking your repository using the Netlify UI. Go to **Site configuration > Build & deploy > Continuous deployment > Repository**, select **Manage repository**, then **Link to a different repository**. After doing this, check your webhook settings at your Git provider to ensure you don't have any duplicate Netlify webhooks.

Please note that your GitHub, GitLab, Bitbucket, or Azure DevOps user account may not have the privilege level required to link the repo to Netlify, even if you can log in and access it from the Git host’s website. You generally need administrative privileges on the repository, owning organization, or both.

In rare cases (about 1% of the time), there might be some other problem with cloning your repo, such as issues with Git LFS, Large Media, or some other git-related situation. In these cases, the Netlify Support team will need to look into the internal logs to debug the issue.

I unlinked and relinked the repository, I still get the same issue.

The Netlify app permission seem to be correct:

Netlify seems to be connected correctly to the repository:

Repository
Your site is linked to a Git repository for continuous deployment.
Current repository
github.com/SCORING-FIT/leaderboard_front

This use to work before, all that changed is the ownership of the repository from a normal git user to an organization.

I hope someone can help,

Thank you in advance,

I have also setup a Deploy key (ssh) in both netlify and the targeted git organization, it did not work

This is getting urgent, can anyone help please :pray:

Does switching back to normal user instead of org fix the issue?

i have not tried that yet, should i? i mean i want it to work with the git orga, but i did plan to return it back to the normal user if no fix was found.

That’s just a potential thought. It might or might not help and currently unblocking you is probably more important than living with the constraints.

If that works, we can think or ways to get the org setup working.

true, but lets say we move it back to normal, how would we be able to find a solution to the actual issue, it would mean that we would have to move it again to orga some other time to test, i am ok with this if you are saying that there is nothing we can check for right now?

Maybe you can try to clone your repo inside the org to see if it makes a difference? So you’d have a copy in your own account and one in the org.

true, i will do that. but i feel like you are not trying to help me fix the issue, more like undo my changes. Does this mean you are considering this possibly not fixable?

You replied to an old topic, and also created a new topic. In both the threads you make this sound like it’s urgent. It’s been about 4 hours since I first posted and yet here I’m trying to convince you to try undoing the change that you made that triggered this issue.

I could be wrong, but my understanding of an “urgent” issue is that, you’d need a fix or a workaround first and then you can continue figuring out why your previous attempt did not work. If you can keep something broken just to figure out what’s wrong, then the issue cannot be urgent. Both of these cannot happen at the same time.

I already mentioned:

But yet, you say:

Not sure how you made that connection.

I think this is a very logical step in debugging an issue. If you change something and that produces an unexpected result, one of the most logical steps in my opinion is to undo that change and get back to a working state. Then we can tread carefully to understand where things start breaking. I’m not an expert, so I could be wrong about my reasoning, so if you don’t feel this is the right way to proceed, you’re free to skip it.


As for your issue, you can try to completely uninstall the Netlify app from your settings and authorize it again. Maybe that would make a difference?

hmmmm, i did not mean to start a fire, my bad, you are right, i will try the undo strategy, and have a copy in the git organization, and just after that i will try the uninstall approach of the Netlify app.

I moved ownership to a normal user, and reconnected Netlify to it, it did not work, i added the new Netlify Deploy key to the repository, and it did not work, i uninstalled Netlify app and re-linked the site, still same error :

Ok, I have managed to fix it, more like get it back to stable version.

In short, it was an npm package issue. Before the ownership transfer the package-lock was probably cached, I am guessing as soon as i re-linked the project, a new package-lock was created, for some reason the new one caused a dependency’s dependency to have permission issues.

My fix was to include the older version of the package-lock and removing it from .gitignore

It seems to work for now.

Thank you for your time, sorry for any inconveniences.

thanks for writing back in and sharing your solution with the community! (: