Skip to content

Fix #78: clear error when a configured branch does not exist#92

Merged
jensens merged 2 commits into
mainfrom
fix/78-better-branch-error
May 31, 2026
Merged

Fix #78: clear error when a configured branch does not exist#92
jensens merged 2 commits into
mainfrom
fix/78-better-branch-error

Conversation

@jensens
Copy link
Copy Markdown
Member

@jensens jensens commented May 31, 2026

Fixes #78.

Problem

When a branch configured in mx.ini does not exist on the remote, mxdev reported it poorly:

  • a generic GitError("git cloning of '<name>' failed.\n<raw git stderr>"), with the real reason (fatal: Remote branch X not found in upstream origin) buried in stderr, plus
  • a full Python traceback (the worker logged expected operational WCErrors with logger.exception).
  • On the update path the missing branch produced a terse No such branch X followed by a hard sys.exit(1).

(Root-cause analysis: see issue comment.)

Approach

A — clear, actionable message. git_checkout detects the "remote branch not found" clone failure and raises a message naming the package, branch and URL, pointing at the mx.ini setting:

Branch 'fix/Issuer-create' for package 'edutap.wallet_google' does not exist at 'https://…'. Check the 'branch' setting for [edutap.wallet_google] in your mx.ini.

B — no scary traceback for expected errors. The worker logs WCErrors as a plain logger.error(<message>); the full traceback drops to logger.debug (available when debugging, hidden in normal runs).

Update path. git_switch_branch and the defensive check in git_merge_rbranch now raise the same clear GitError instead of logger.error(...) + sys.exit(1), so the failure flows through normal error handling consistently with the clone path.

Status

Draft contains the failing tests reproducing both the checkout and update cases. Fix follows next.

Test Plan

  • test_checkout_missing_branch_gives_clear_error
  • test_update_missing_branch_gives_clear_error
  • updated test_worker_with_error (asserts the real message, not the generic one)
  • full suite + lint green

jensens added 2 commits May 31, 2026 23:50
- git_checkout detects 'remote branch not found' clone failures and raises a
  message naming the package, branch and URL, pointing at the mx.ini setting.
- git_switch_branch and git_merge_rbranch raise the same clear GitError instead
  of logging a terse 'No such branch' and calling sys.exit(1), so the update path
  behaves consistently with checkout.
- The worker reports expected WCErrors as a plain error message and keeps the full
  traceback at debug level only.
@jensens jensens marked this pull request as ready for review May 31, 2026 21:56
@jensens jensens merged commit 673ffbc into main May 31, 2026
17 checks passed
@jensens jensens deleted the fix/78-better-branch-error branch May 31, 2026 21:59
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.

Feat: Better error when a branch no longer exists

1 participant