fix: friendly error when bruin CLI cannot find a git repository#759
Open
DjamilaBaroudi wants to merge 1 commit into
Open
fix: friendly error when bruin CLI cannot find a git repository#759DjamilaBaroudi wants to merge 1 commit into
DjamilaBaroudi wants to merge 1 commit into
Conversation
Detect "no git repository found" and "failed to find the git repository root" in CLI output and replace them with a single actionable message guiding users to run `git init` at their project root. Wired into validate, connections list, and render error paths. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Prompt To Fix All With AIFix the following 1 code review issue. Work through them one at a time, proposing concise fixes.
---
### Issue 1 of 1
src/test/extension.test.ts:1106-1111
**Second pattern test doesn't isolate pattern 2**
The string `"Failed to find the git repository root: no git repository found"` also satisfies the first pattern (`/no git repository found/i`), so this test would pass even if the second entry in `NO_GIT_REPO_PATTERNS` were removed. A string like `"Failed to find the git repository root"` (without the `: no git repository found` suffix) would uniquely exercise the second pattern.
```suggestion
test("maps 'failed to find the git repository root' to the friendly message", () => {
assert.strictEqual(
friendlifyBruinError("Failed to find the git repository root"),
FRIENDLY_NO_GIT_REPO_MESSAGE
);
});
```
Reviews (1): Last reviewed commit: "fix: surface friendly error when bruin C..." | Re-trigger Greptile |
Comment on lines
+1106
to
+1111
| test("maps 'failed to find the git repository root' to the friendly message", () => { | ||
| assert.strictEqual( | ||
| friendlifyBruinError("Failed to find the git repository root: no git repository found"), | ||
| FRIENDLY_NO_GIT_REPO_MESSAGE | ||
| ); | ||
| }); |
There was a problem hiding this comment.
Second pattern test doesn't isolate pattern 2
The string "Failed to find the git repository root: no git repository found" also satisfies the first pattern (/no git repository found/i), so this test would pass even if the second entry in NO_GIT_REPO_PATTERNS were removed. A string like "Failed to find the git repository root" (without the : no git repository found suffix) would uniquely exercise the second pattern.
Suggested change
| test("maps 'failed to find the git repository root' to the friendly message", () => { | |
| assert.strictEqual( | |
| friendlifyBruinError("Failed to find the git repository root: no git repository found"), | |
| FRIENDLY_NO_GIT_REPO_MESSAGE | |
| ); | |
| }); | |
| test("maps 'failed to find the git repository root' to the friendly message", () => { | |
| assert.strictEqual( | |
| friendlifyBruinError("Failed to find the git repository root"), | |
| FRIENDLY_NO_GIT_REPO_MESSAGE | |
| ); | |
| }); |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/test/extension.test.ts
Line: 1106-1111
Comment:
**Second pattern test doesn't isolate pattern 2**
The string `"Failed to find the git repository root: no git repository found"` also satisfies the first pattern (`/no git repository found/i`), so this test would pass even if the second entry in `NO_GIT_REPO_PATTERNS` were removed. A string like `"Failed to find the git repository root"` (without the `: no git repository found` suffix) would uniquely exercise the second pattern.
```suggestion
test("maps 'failed to find the git repository root' to the friendly message", () => {
assert.strictEqual(
friendlifyBruinError("Failed to find the git repository root"),
FRIENDLY_NO_GIT_REPO_MESSAGE
);
});
```
How can I resolve this? If you propose a fix, please make it concise.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
no git repository found/failed to find the git repository rootin bruin CLI output and replace with a single actionable message: "Bruin requires a git repository. Rungit initat your project root, then reload the window."friendlifyBruinError+ constantFRIENDLY_NO_GIT_REPO_MESSAGEinsrc/utilities/helperUtils.ts.bruinValidate.ts), connections list (bruinConnections.ts), and renderparseError(bruinRender.ts).Errorinputs, andnull/undefined.Context
Related to BRU-2675. The ticket's "incorrect workspace root folder" framing turned out to be a red herring — bruin CLI walks up from the file path (not cwd/workspace) to find
.git, so the workspace root location does not matter. The real cause was a missing git repo in the user's project, and the CLI errors surfaced today are unfriendly. This PR doesn't change the CLI requirement; it just makes the failure actionable.Render currently keeps showing the generic "failed to mutate the asset" because the CLI itself drops the underlying cause for the
rendersubcommand — that's a separate upstream fix inbruin-data/bruin. Once fixed there, this PR's helper will cover render automatically with no further extension changes.Test plan
tsc -p ./ --noEmitcleaneslintclean on all touched files.gitancestor, click Validate → expect friendly message instead ofno git repository foundfailed to find the git repository root.git→ confirm normal flows still work (no regressions)🤖 Generated with Claude Code