You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Refactor: Add automatic token refresh to git push operations to prevent auth failures #99
The 'worker.js' process occasionally fails during 'git push' operations with an "Authentication failed" error from GitHub. This occurs because the GitHub App installation token, which is valid for only one hour, is fetched at the start of a job. If a job, especially the AI-driven Claude execution phase, takes a significant amount of time to complete, the token can expire before the final push operation is executed. The current retry mechanism is not effective in this scenario as it repeatedly uses the same expired token.
The goal of this task is to make the git push operation more robust by incorporating an automatic token refresh mechanism when an authentication failure is detected.
Implementation Instructions
To resolve this, you'll need to modify the 'pushBranch' function in 'src/git/repoManager.js' to handle authentication errors gracefully.
Import Authentication Utility:
In 'src/git/repoManager.js', add an import for 'getAuthenticatedOctokit' from '../auth/githubAuth.js'.
Refactor 'pushBranch' Function:
The existing logic within 'pushBranch' should be extracted into a local async helper function, let's call it 'performPush'. This function will accept the token as an argument.
The main 'pushBranch' function will now contain the primary try/catch logic.
Implement Retry Logic:
In the main 'pushBranch' function, make an initial call to 'performPush' with the 'authToken' passed in the options.
Wrap this call in a 'try...catch' block.
In the 'catch' block, check if the error message contains "Authentication failed" or "Invalid username or token".
If it's an authentication error:
Log that an authentication error was detected and a token refresh is being attempted.
Call 'getAuthenticatedOctokit()' to get a new instance.
Get a fresh token by calling '.auth({ type: "installation" })' on the new octokit instance.
Retry the push operation by calling 'performPush' again, this time with the newly acquired token.
If this retry also fails, the error should be thrown.
If the original error was not an authentication error, it should be re-thrown immediately.
Activity
integry commentedon Oct 7, 2025
Here is the suggested implementation:
File:
src/git/repoManager.jspropr-dev commentedon Oct 7, 2025
🤖 AI processing has started for this issue using claude-sonnet-4-5-20250929 model.
I'll analyze the problem and work on a solution. This may take a few minutes.
Processing Details:
claude-sonnet-4-5-20250929ai-fix/99-refactor-add-automatic-to-20251007-1159-claude-sonnet-4-5-20250929-j4omainissue-99-20251007-1159-claude-sonnet-4-5-20250929-j4ofix(ai): Resolve issue #99 - Refactor: Add automatic token refresh to…
Merge pull request #100 from integry/ai-fix/99-refactor-add-automatic…
All tasks are complete. Here's a summary of what was implemented:
All tasks are complete. Here's a summary of what was implemented: