Unable to deploy new site with Github repo from Netlify API

I’m trying to deploy a new site via NetlifyAPI with a private Github repo. When I deploy for the first time the site, I got the following error inside the first deploy :

3:51:47 PM: Build ready to start
3:51:49 PM: build-image version: d7b3dbfb0846505993c9a131894d1858074c90b4 (focal)
3:51:49 PM: build-image tag: v4.10.1
3:51:49 PM: buildbot version: f7070267d9348624fde5c2d682aa32cc686742a6
3:51:49 PM: Fetching cached dependencies
3:51:49 PM: Failed to fetch cache, continuing with build
3:51:49 PM: Starting to prepare the repo for build
3:51:49 PM: User git error while checking for ref refs/heads/master
3:51:49 PM: Creating deploy upload records
3:51:49 PM: Failing build: Failed to prepare repo
3:51:49 PM: Failed during stage 'preparing repo': error checking for ref: fatal: could not read Username for 'https://github.com': No such device or address: exit status 128
3:51:49 PM: Finished processing build request in 650.822902ms

But, if I trigger the “Retry” button, the second deploy works fine :

4:00:52 PM: Build ready to start
4:01:06 PM: build-image version: d7b3dbfb0846505993c9a131894d1858074c90b4 (focal)
4:01:06 PM: build-image tag: v4.10.1
4:01:06 PM: buildbot version: f7070267d9348624fde5c2d682aa32cc686742a6
4:01:06 PM: Building without cache
4:01:06 PM: Starting to prepare the repo for build
4:01:06 PM: No cached dependencies found. Cloning fresh repo
4:01:06 PM: git clone https://github.com/MediakodTeam/astroblok-design-system
4:01:07 PM: Preparing Git Reference refs/heads/master
4:01:07 PM: Parsing package.json dependencies
4:01:08 PM: Starting build script
4:01:08 PM: Installing dependencies
4:01:08 PM: Python version set to 2.7
4:01:09 PM: Downloading and installing node v16.14.0...
4:01:09 PM: Downloading https://nodejs.org/dist/v16.14.0/node-v16.14.0-linux-x64.tar.xz...
4:01:09 PM: Computing checksum with sha256sum
4:01:10 PM: Checksums matched!
4:01:11 PM: Now using node v16.14.0 (npm v8.3.1)
4:01:11 PM: Started restoring cached build plugins
4:01:11 PM: Finished restoring cached build plugins
4:01:12 PM: Attempting ruby version 2.7.2, read from environment
4:01:12 PM: Using ruby version 2.7.2
4:01:12 PM: Using PHP version 8.0
4:01:12 PM: Started restoring cached yarn cache
4:01:12 PM: Finished restoring cached yarn cache
4:01:13 PM: No yarn workspaces detected
4:01:13 PM: Started restoring cached node modules
4:01:13 PM: Finished restoring cached node modules
4:01:13 PM: Installing NPM modules using Yarn version 1.22.10
4:01:13 PM: yarn install v1.22.10
4:01:13 PM: [1/4] Resolving packages...
4:01:13 PM: [2/4] Fetching packages...
...

:gear: Settings used by Netlify :

API Body to create site :

{  
    "name": "test-ds-via-api",
    "url": "https://test-ds-via-api.netlify.app",
    "repo": {
        "provider": "github",
        "branch" : "master",
        "repo": "MediakodTeam/astroblok-design-system",
        "private" : "false",
        "cmd" : "yarn build",
        "dir": "dist/",
        "env": {
            "foo": "bar"
        }
    }
}

Continuous Deployment settings :

Site slug : test-ds-via-api

Hey there, @loganb :wave:

Thanks for reaching out and welcome to the Forums. I have done some digging, and it looks like other Forums members have encountered something similar. Can you please read through this thread and see if the solution shared gets you on the right track?

Thanks! I will stay tuned for a response