Skip to content

Commit 0504000

Browse files
committed
Fix spawn failures being misreported as CLI unavailable
Only classify VcsProcessSpawnError as GitHubCliUnavailableError when the underlying cause is ENOENT (binary not found). Other spawn failures such as EACCES (permission denied) now correctly fall through to GitHubCliCommandError instead of misleading users to install gh.
1 parent e04ad5d commit 0504000

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

apps/server/src/sourceControl/GitHubCli.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,14 @@ export type GitHubCliError = typeof GitHubCliError.Type;
161161

162162
export const isGitHubCliError = Schema.is(GitHubCliError);
163163

164+
function isEnoentCause(cause: unknown): boolean {
165+
if (typeof cause === "object" && cause !== null && "code" in cause) {
166+
return (cause as { code: unknown }).code === "ENOENT";
167+
}
168+
const text = String(cause).toLowerCase();
169+
return text.includes("enoent") || text.includes("command not found");
170+
}
171+
164172
export function fromVcsError(
165173
context: {
166174
readonly operation: "execute";
@@ -170,7 +178,10 @@ export function fromVcsError(
170178
error: VcsError,
171179
): GitHubCliError {
172180
if (error._tag === "VcsProcessSpawnError") {
173-
return new GitHubCliUnavailableError({ ...context, cause: error });
181+
if (isEnoentCause(error.cause)) {
182+
return new GitHubCliUnavailableError({ ...context, cause: error });
183+
}
184+
return new GitHubCliCommandError({ ...context, cause: error });
174185
}
175186

176187
if (error._tag === "VcsProcessExitError") {

0 commit comments

Comments
 (0)