Github App Authorisation fails on a long build chain

Description of the issue

We have recently migrated from using Github OAuth to Github App for Bitrise ↔ Github access management and there appears to be an issue with starting too many builds in parallel.

It appears that auth token is generated when the build is created, even if that build is on hold which leads to the token expiring if hold time is long, which in its turn leads to Git Clone step failing due to invalid credentials.

Environment:

Where did the issue happen?

Ubuntu Noble 24.04 - Bitrise 2025 Edition • Linux AMD Zen4 Medium

Which build Step causes the issue and which version of the step?

Git Clone Repository v8.5.1

Reproducibility

  • Does a “Rebuild” help? (You can trigger a rebuild from the Build’s page, by clicking the “Rebuild” button in the top right corner of a finished build) : YES
  • Does a rebuild without caches help? (You can remove the Cache:Pull and Cache:Push steps temporarily to not to use the cache, or you can delete all the caches on the Settings tab of the app. : YES
  • Does the issue happen sporadically, or every time? : When hold time is large enough, approximately 1h
  • Does upgrading the build Step to the latest version help? : NO
  • When did the issue start? : Migrating to Github App integration

Build log

Input:
- merge_pr: true
- git_http_username: <unset>
- git_http_password: [REDACTED]
- clone_into_dir: /bitrise/src
- clone_depth: 0
- update_submodules: true
- submodule_update_depth: 0
- fetch_tags: false
- sparse_directories: []
- ignore_branch_for_commit_fetch: false
- repository_url: https://github.com/...git
- commit: <unset>
- tag: <unset>
- branch: v4-prod
- branch_dest: <unset>
- pull_request_repository_url: <unset>
- pull_request_merge_branch: <unset>
- pull_request_unverified_merge_branch: <unset>
- pull_request_head_branch: <unset>
- reset_repository: false
- performance_monitoring: false
- build_url: https://app.bitrise.io/app/0d7163b08386e81f/build/6edf1940-16f0-4597-972a-c5bf212f79be
- build_api_token: [REDACTED]
Writing .netrc file...
No .netrc file found at (/root/.netrc), creating new...

$ git "init"
hint: Using 'master' as the name for the initial branch. This default branch name
hint: will change to "main" in Git 3.0. To configure the initial branch name
hint: to use in all of your new repositories, which will suppress this warning,
hint: call:
hint:
hint: 	git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint: 	git branch -m <name>
hint:
hint: Disable this message with "git config set advice.defaultBranchName false"
Initialized empty Git repository in /bitrise/src/.git/

$ git "remote" "add" "origin" "https://github.com/...git"

$ git "config" "gc.auto" "0"

$ git "fetch" "--jobs=10" "--depth=1" "--no-tags" "origin" "refs/heads/v4-prod"
remote: Invalid username or token. Password authentication is not supported for Git operations.
fatal: Authentication failed for 'https://github.com/...git/'
Attempt 1 failed:
remote: Invalid username or token. Password authentication is not supported for Git operations.
fatal: Authentication failed for 'https://github.com/...git/'
Retrying...

$ git "fetch" "--jobs=10" "--depth=1" "--no-tags" "origin" "refs/heads/v4-prod"
remote: Invalid username or token. Password authentication is not supported for Git operations.
fatal: Authentication failed for 'https://github.com/...git/'
Attempt 2 failed:
remote: Invalid username or token. Password authentication is not supported for Git operations.
fatal: Authentication failed for 'https://github.com/...git/'
Retrying...

$ git "fetch" "--jobs=10" "--depth=1" "--no-tags" "origin" "refs/heads/v4-prod"
remote: Invalid username or token. Password authentication is not supported for Git operations.
fatal: Authentication failed for 'https://github.com/...git/'
Attempt 3 failed:
remote: Invalid username or token. Password authentication is not supported for Git operations.
fatal: Authentication failed for 'https://github.com/...git/'

$ git "remote" "-v" &> out

$ git "ls-remote" "-b" &> out
Checkout strategy used: gitclone.checkoutBranch

Failed to execute Step:
  fetch branch refs/heads/v4-prod: remote: Invalid username or token. Password authentication is not supported for Git operations.
  fatal: Authentication failed for 'https://github.com/...git/':
    please make sure the branch still exists

Despite that scary log simply restarting the build works, as well as all previous builds targeting the same branch.