GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(gitlab): name the cause of a failed glab command by Sinan53x · Pull Request #22509 · pingdotgg/t3code

fix(gitlab): name the cause of a failed glab command #22509

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Sinan53x wants to merge 1 commit into pingdotgg:main from Sinan53x:fix/gitlab-cli-error-reason

Uh oh!

There was an error while loading. Please reload this page.

Closed

fix(gitlab): name the cause of a failed glab command #22509

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
1 commit
Select commit
53bd547
fix(gitlab): name the cause of a failed glab command
Oct 20, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

86 changes: 83 additions & 3 deletions 86 packages/source-control-gitlab/src/server/GitLabCli.test.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as Effect from "effect/Effect";
import * as Layer from "effect/Layer";
import { ChildProcessSpawner } from "effect/process";

import { VcsProcessExitError } from "@t3tools/contracts";
import { VcsProcessExitError, VcsProcessTimeoutError } from "@t3tools/contracts";

import type * as SourceControlHost from "@t3tools/source-control-core/server/SourceControlHost";
import * as TestSourceControlHost from "@t3tools/source-control-testing/TestSourceControlHost";
Expand Down Expand Up @@ -182,7 +182,7 @@ layer("GitLabCli.layer", (it) => {
}),
);

it.effect("keeps non-merge-request not-found failures generic", () =>
it.effect("names non-merge-request not-found failures without claiming a missing MR", () =>
Effect.gen(function* () {
const cause = new VcsProcessExitError({
operation: "GitLabCli.execute",
Expand All @@ -202,8 +202,10 @@ layer("GitLabCli.layer", (it) => {
});
}).pipe(Effect.flip);

assert.strictEqual(error._tag, "GitLabCliCommandError");
assert.strictEqual(error.cause, cause);
assert.strictEqual(error.detail, "GitLab CLI command failed (not-found).");
assert(error._tag === "GitLabCliCommandError");
assert.strictEqual(error.reason, "not-found");
}),
);

Expand All @@ -228,4 +230,82 @@ layer("GitLabCli.layer", (it) => {
assert.strictEqual(error.cause, cause);
}),
);

it.effect("names a not-found exit in a failed command's detail", () =>
Effect.gen(function* () {
const cause = new VcsProcessExitError({
operation: "GitLabCli.execute",
command: "glab",
cwd: "/repo",
exitCode: 1,
detail: "Merge request not found.",
failureKind: "not-found",
});
mockedRun.mockReturnValueOnce(Effect.fail(cause));

const glab = yield* GitLabCli.GitLabCli;
const error = yield* glab
.listMergeRequests({ cwd: "/repo", headSelector: "main", state: "open" })
.pipe(Effect.flip);

assert.strictEqual(error.cause, cause);
assert.strictEqual(error.detail, "GitLab CLI command failed (not-found).");
assert(error._tag === "GitLabCliCommandError");
assert.strictEqual(error.reason, "not-found");
assert.notInclude(error.message, "Merge request not found.");
}),
);

it.effect("names recognized failure classes and leaves unclassified exits generic", () =>
Effect.gen(function* () {
const timeoutCause = new VcsProcessTimeoutError({
operation: "GitLabCli.execute",
command: "glab",
cwd: "/repo",
timeoutMs: 30_000,
});
const exitCause = new VcsProcessExitError({
operation: "GitLabCli.execute",
command: "glab",
cwd: "/repo",
exitCode: 1,
detail: "Process exited with a non-zero status.",
failureKind: "command-failed",
});
// The boundary always sets failureKind; an absent one is a schema-optional
// fallback that must still stay generic.
const unclassifiedCause = new VcsProcessExitError({
operation: "GitLabCli.execute",
command: "glab",
cwd: "/repo",
exitCode: 1,
detail: "Process exited with a non-zero status.",
});
mockedRun
.mockReturnValueOnce(Effect.fail(timeoutCause))
.mockReturnValueOnce(Effect.fail(exitCause))
.mockReturnValueOnce(Effect.fail(unclassifiedCause));

const glab = yield* GitLabCli.GitLabCli;
const timedOut = yield* glab
.execute({ cwd: "/repo", args: ["api", "projects"] })
.pipe(Effect.flip);
const failed = yield* glab
.execute({ cwd: "/repo", args: ["api", "projects"] })
.pipe(Effect.flip);
const unclassified = yield* glab
.execute({ cwd: "/repo", args: ["api", "projects"] })
.pipe(Effect.flip);

assert.strictEqual(timedOut.detail, "GitLab CLI command failed (timed-out).");
assert(timedOut._tag === "GitLabCliCommandError");
assert.strictEqual(timedOut.reason, "timed-out");
assert.strictEqual(failed.detail, "GitLab CLI command failed.");
assert(failed._tag === "GitLabCliCommandError");
assert.strictEqual(failed.reason, undefined);
assert.strictEqual(unclassified.detail, "GitLab CLI command failed.");
assert(unclassified._tag === "GitLabCliCommandError");
assert.strictEqual(unclassified.reason, undefined);
}),
);
});
46 changes: 37 additions & 9 deletions 46 packages/source-control-gitlab/src/server/GitLabCli.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as Schema from "effect/Schema";
import type * as DateTime from "effect/DateTime";

import {
ForwardCompatibleOptional,
TrimmedNonEmptyString,
type SourceControlRepositoryVisibility,
type VcsError,
Expand Down Expand Up @@ -114,12 +115,31 @@ export class GitLabMergeRequestNotFoundError extends Schema.TaggedError<GitLabMe
}
}

// The process boundary classifies glab's stderr into these tags and discards
// the raw text, so only a tag can reach detail and message. Unclassified exits
// stay generic rather than claim a cause that was never recognized.
export const GitLabCliCommandFailureReason = Schema.Literals([
"not-found",
"timed-out",
"stdin-write-failed",
"output-read-failed",
"output-limit-exceeded",
"missing-exit-code",
"repository-detection-failed",
"unsupported-operation",
]);
export type GitLabCliCommandFailureReason = typeof GitLabCliCommandFailureReason.Type;

export class GitLabCliCommandError extends Schema.TaggedError<GitLabCliCommandError>()(
"GitLabCliCommandError",
gitLabCliExecutionErrorContext,
{
...gitLabCliExecutionErrorContext,
reason: ForwardCompatibleOptional(GitLabCliCommandFailureReason),
},
) {
get detail(): string {
return "GitLab CLI command failed.";
const reason = this.reason === undefined ? "" : ` (${this.reason})`;
return `GitLab CLI command failed${reason}.`;
}

override get message(): string {
Expand All @@ -143,18 +163,26 @@ export class GitLabCliCommandError extends Schema.TaggedError<GitLabCliCommandEr
case "rate-limited":
return new GitLabCliRateLimitError({ ...context, cause });
case "not-found":
return new GitLabCliCommandError({ ...context, cause, reason: "not-found" });
case "command-failed":
case undefined:
return new GitLabCliCommandError({ ...context, cause });
}
},
VcsProcessTimeoutError: (cause) => new GitLabCliCommandError({ ...context, cause }),
VcsProcessStdinWriteError: (cause) => new GitLabCliCommandError({ ...context, cause }),
VcsProcessOutputReadError: (cause) => new GitLabCliCommandError({ ...context, cause }),
VcsProcessOutputLimitError: (cause) => new GitLabCliCommandError({ ...context, cause }),
VcsProcessMissingExitCodeError: (cause) => new GitLabCliCommandError({ ...context, cause }),
VcsRepositoryDetectionError: (cause) => new GitLabCliCommandError({ ...context, cause }),
VcsUnsupportedOperationError: (cause) => new GitLabCliCommandError({ ...context, cause }),
VcsProcessTimeoutError: (cause) =>
new GitLabCliCommandError({ ...context, cause, reason: "timed-out" }),
VcsProcessStdinWriteError: (cause) =>
new GitLabCliCommandError({ ...context, cause, reason: "stdin-write-failed" }),
VcsProcessOutputReadError: (cause) =>
new GitLabCliCommandError({ ...context, cause, reason: "output-read-failed" }),
VcsProcessOutputLimitError: (cause) =>
new GitLabCliCommandError({ ...context, cause, reason: "output-limit-exceeded" }),
VcsProcessMissingExitCodeError: (cause) =>
new GitLabCliCommandError({ ...context, cause, reason: "missing-exit-code" }),
VcsRepositoryDetectionError: (cause) =>
new GitLabCliCommandError({ ...context, cause, reason: "repository-detection-failed" }),
VcsUnsupportedOperationError: (cause) =>
new GitLabCliCommandError({ ...context, cause, reason: "unsupported-operation" }),
});
}
}
Expand Down
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

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.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.