Skip to content

[Bug]: GitLab "Create MR" fails with snap-installed glab — PR body temp file in /tmp is invisible to the snap sandbox #31743

Closed

Description

@allnightlong

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

Server — git actions / source control (GitLab provider)

Steps to reproduce

  1. Linux (here: WSL2 Ubuntu) with glab installed from the Snap Store (snap install glab, strict confinement), authenticated and working (glab mr list succeeds).
  2. Open a GitLab-hosted project in T3 Code, push a branch.
  3. Press the git action button with Create MR (create_pr) or Commit, push & create MR (commit_push_pr).

Minimal repro without T3 Code, same command shape T3 Code uses:

echo test > /tmp/body.md
glab api --method GET projects/:fullpath --field description=@/tmp/body.md
#   ERROR  error parsing "description" value: open /tmp/body.md: no such file or directory.

echo test > ~/body.md
glab api --method GET projects/:fullpath --field description=@$HOME/body.md
#   200 OK

Expected behavior

The merge request is created, as it is when the same branch's MR is created with glab mr create --description "..." from a shell.

Actual behavior

The action fails with:

Source control provider gitlab failed in createChangeRequest: GitLab CLI command failed.

Root cause:

  • runPrStep (apps/server/src/git/GitManager.ts) always writes the generated body to $TMPDIR ?? $TEMP ?? $TMP ?? "/tmp" as t3code-pr-body-<pid>-<uuid>.md.
  • GitLabCli.createMergeRequest (packages/source-control-gitlab/src/server/GitLabCli.ts) passes it as glab api --method POST projects/:fullpath/merge_requests ... --field description=@<bodyFile>.
  • Strictly confined snaps get a private /tmp (/tmp/snap-private-tmp/snap.glab/tmp), so glab cannot open the host's /tmp/t3code-pr-body-*.md and exits 1. glab's snap does have the home plug, so a file under $HOME works.

This has been the behavior since GitLab support landed (0ce7e56e43, description=@${input.bodyFile}) and is unchanged on main (e136e8e3d4).

Read-only glab calls (mr list, mr view, api projects/:fullpath) work, so the provider looks healthy right up until creation fails.

Secondary issue: the surfaced error drops glab's stderr. The UI only says "GitLab CLI command failed.", and the server trace only has exited with 1 - Process exited with a non-zero status., so the real cause (open /tmp/...: no such file or directory) is not visible anywhere.

Suggested fix

Any of these would work:

  • Pass the description without a file. The smallest change is --field description=@- with the body written to the child's stdin, since glab reads @- from standard input. --input - (raw JSON body over stdin) would also work.
  • Write the body file somewhere snaps can read, such as a directory under the T3 data dir in $HOME, instead of os.tmpdir().
  • At minimum, include the CLI's stderr in GitLabCliCommandError so users can see why it failed.

The GitHub path (gh pr create --body-file) probably has the same problem when gh is installed as a snap, although gh is usually installed from apt.

Impact

Major for affected setups: creating an MR from the git action button never works with snap-installed glab, which is the default glab install on Ubuntu. No workaround inside T3 Code. The user has to create MRs from a shell or install glab another way.

Version or commit

Server 0.1.7 (WSL runtime sha256-c089892b…, also reproduced on the previous runtime sha256-7cf31da9…). Matching code on main @ e136e8e3d4.

Environment

  • Windows 11 desktop app "T3 Code (Beta)", backend running in WSL2 (Ubuntu), kernel 6.18.33.2-microsoft-standard-WSL2
  • glab 1.128.0 (snap rev 7114, confinement: strict, plugs: home, …). Also strict in the previous rev 6906 (1.123.0).
  • T3 server process environment has no TMPDIR, so the body file goes to /tmp.

Logs or stack traces

GitLabCli.createMergeRequest  Failure
  GitLabCliCommandError: GitLab CLI failed in execute: GitLab CLI command failed.
VcsProcess.runUnbounded       Failure
  VcsProcessExitError: VCS process failed in GitLabCli.execute: glab (<worktree>) exited with 1 - Process exited with a non-zero status.
GitLabSourceControlProvider.createChangeRequest  Failure
  SourceControlProviderError: Source control provider gitlab failed in createChangeRequest: GitLab CLI command failed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions