Skip to content

Comments

fix: handle detached HEAD state in bench update#1685

Open
RendaniSinyage wants to merge 4 commits intofrappe:developfrom
RendaniSinyage:develop
Open

fix: handle detached HEAD state in bench update#1685
RendaniSinyage wants to merge 4 commits intofrappe:developfrom
RendaniSinyage:develop

Conversation

@RendaniSinyage
Copy link

Currently, bench update crashes if an app is pinned to a specific tag/version (Detached HEAD) because git symbolic-ref fails. This fix catches that error and skips the update for those specific apps.

What type of a PR is this?

  • Changes to Existing Features
  • New Feature Submissions
  • Bug Fix
  • Breaking Change (include change in API behaviours, etc.)

Please provide enough information so that others can review your pull request:

This PR fixes a crash in bench update when an app is checked out to a specific tag or commit hash (Detached HEAD state).

The Problem:
When an app is pinned (e.g., v1.0.0), it has no active branch. The command git symbolic-ref -q --short HEAD fails with exit code 1, causing the entire bench update process to crash.

The Fix:

  1. Modified get_current_branch in bench/utils/app.py to catch the exception and return None if no branch is found (Detached HEAD).
  2. Updated pull_apps in bench/app.py to check for None. If detected, it logs a message and skips the git pull for that specific app, allowing the rest of the update to proceed.

Explain the details for making this change. What existing problem does the pull request solve? The following checklist could help

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  • Have you lint your code locally prior to submission?
  • Have you successfully run tests with your changes locally?
  • Does your commit message have an explanation for your changes and why you'd like us to include them?
  • Docs have been added / updated
  • Tests for the changes have been added (for bug fixes / features)
  • Did you modify the existing test cases? If yes, why?

Screenshots/GIFs

N/A - CLI fix.

Currently, bench update crashes if an app is pinned to a specific tag/version (Detached HEAD) because git symbolic-ref fails. This fix catches that error and skips the update for those specific apps.
fix: handle detached HEAD state in bench update
@akhilnarang
Copy link
Member

2. Updated pull_apps in bench/app.py to check for None. If detected, it logs a message and skips the git pull for that specific app, allowing the rest of the update to proceed.

I don't see this part implemented in your PR. Currently there seems to be a few usages of this method which don't handle the None return.

@akhilnarang akhilnarang marked this pull request as draft January 27, 2026 08:23
@akhilnarang
Copy link
Member

Do tag me whenever you implement the changes.

@akhilnarang
Copy link
Member

You've changed the formatting of the entire file - could you revert that? Also the comment added can be removed.

@RendaniSinyage
Copy link
Author

@akhilnarang fixed

@RendaniSinyage RendaniSinyage marked this pull request as ready for review January 27, 2026 12:54
@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants