fix: authenticate glab and agent CLIs through the login shell environment - #149
Merged
cpojer merged 5 commits intoJul 29, 2026
Merged
Conversation
Member
|
Nice! |
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.
Follow-up to #144, which fixed
ghauthentication for GUI launches and leftglabout of scope. Same story: a Dock-launched Codiff inherits launchd's minimal environment, the single-instance lock keeps it for the lifetime of the process, andglabnever sees aGITLAB_TOKENthat only exists as a login shell export. GitLab requests fail with:While auditing the other spawn sites for the same gap, I found the agent CLIs have it too:
claude,codex(exec and app-server),opencode(run and serve) andpiall spawn with plainprocess.env, so keys likeANTHROPIC_API_KEYorOPENAI_API_KEYthat only live in the user's shell profile never reach them from a GUI launch.This PR:
getCommandEnvironmenttologin-shell-environment.cjs:{ ...(await getLoginShellEnvironment()), ...process.env }, so the login shell only fills variables the process doesn't already haveglabwith it inglabApi, mirroring theghfixOPENCODE_PERMISSIONas an explicit override on top for OpenCoderunGhApithrough the same helper so the precedence rule is defined oncebeforeEachthat clearsSHELL, since every runner now resolves the login shell; the new tests bring their own fake login shellThe commits are ordered test first, then fix, for both halves. The glab regression test fails on the exact error above before the implementation, and the agent tests assert the spawned environment through the existing command transport capture, including that the process environment wins over the login shell.
I looked at the remaining spawn sites and left them alone on purpose:
opencode exportreads local session files,cloudflaredauthenticates through a browser flow and an on-disk cert, and the git spawns work fine from GUI launches today.Created with Fable 5 xhigh, reviewed by Sol 5.6 xhigh.