Merged
Size
S
Change Breakdown
Bug Fix90%
Maintenance10%
#28422fix(core): Handle git fetch failure during source control startup

Git auth failures no longer crash startup

n8n instances with Git source control can now survive authentication failures on startup, logging a warning and allowing users to fix credentials through the UI instead of crashing and locking themselves out.

When n8n starts with source control configured over HTTPS and the local git folder is missing or incomplete, it attempts to initialize a repository. If the git authentication token has expired or been revoked, the fetch operation would fail with an unhandled exception — crashing the entire application before the UI ever loaded. This created a recovery deadlock: users couldn't access n8n to fix the credentials and had to edit the database directly.

The fix wraps the git fetch call during remote tracking setup in a try-catch block. When authentication fails and the error is recoverable, n8n now logs a warning and continues starting instead of propagating the exception. The UI becomes available, and users can update their GitHub credentials through the normal settings flow.

This applies to the file in the n8n CLI package.

View Original GitHub Description

Summary

[!IMPORTANT]
I'd like to get more hands on this, I cannot really reproduce the issue with the steps provided because if someone has their HTTPs with git, a git folder must be already there, the way I reproduced this differed a bit from the ticket which is why I need someone to validate this with me please after watching the video below 👇

https://www.loom.com/share/c9844d430fb140188f1a1cfb91addc1a

When n8n starts with source control (Environments) configured over HTTPS and the local git folder is absent or incomplete (e.g. fresh pod, ephemeral filesystem, or manually deleted folder), it calls initRepository()trackRemoteIfReady()fetch(). If the HTTPS token is expired or revoked, the authentication error was unhandled and propagated all the way up, crashing the process on startup.

This created a recovery deadlock: the UI never became available, so users couldn't fix the credentials through the UI and had to edit the database directly.

Root cause: trackRemoteIfReady() called fetch() without a try-catch, unlike the sibling method ensureBranchSetup() which already handles fetch errors gracefully.

Fix: Wrap the fetch() call in trackRemoteIfReady() with the same try-catch pattern used in ensureBranchSetup() — log a warning and return early, letting sanityCheck() surface the error once the instance is up.

How to reproduce:

  1. Configure source control with a GitHub HTTPS remote and token
  2. Revoke the token
  3. Delete the local git folder (~/.n8n/gitFolder or equivalent)
  4. Restart n8n — observe startup crash
  5. With this fix: n8n starts, logs a warning, and the user can fix credentials via the UI

Related Linear tickets, Github issues, and Community forum posts

https://linear.app/n8n/issue/LIGO-453 closes https://github.com/n8n-io/n8n/issues/28311

Review / Merge checklist

  • I have seen this code, I have run this code, and I take responsibility for this code.
  • PR title and summary are descriptive. (conventions)
  • Docs updated or follow-up ticket created.
  • Tests included.
  • PR Labeled with Backport to Beta, Backport to Stable, or Backport to v1 (if the PR is an urgent fix that needs to be backported)

🤖 PR Summary generated by AI

© 2026 · via Gitpulse