You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
pr create --as-user <login> reports not a collaborator despite valid host gh access #159
gcb pr create --as-user JounQin fails with GraphQL: must be a collaborator (createPullRequest) even though the host gh account is the correct user and has push access.
Environment
gcb version: 0.11.0 (host broker)
host broker had the target repository added to its allowlist and was reloaded
~/.config/gh-JounQin was created/available to the host broker
Steps
Host gh is authenticated as the intended account and can read/write the repository:
Checked the host route: it passes --head through to gh pr create unchanged, sets GH_CONFIG_DIR=~/.config/gh-<login> and GH_HOST=github.com, and runs in the checkout/channel it is serving.
must be a collaborator (createPullRequest) is about the head repository, not necessarily push access to --repo. With a bare --head <branch>, gh infers the head repository from the checkout it runs in; if the host broker is serving a different checkout (or the global channel), that can resolve to a repository where JounQin is not a collaborator, even though --repo push access is fine.
To narrow it down, could you share sanitized:
the exact --head value (a bare branch or <remote>:<branch>)
git remote -v and the current branch in the checkout where the request ran
whether the branch is pushed to the target repo or to JounQin's fork
whether the same flags work when run directly on the host from a checkout of the target: gh pr create --repo <owner>/<repo> --head <branch> --base next --title ...
If the branch is in a fork, --head <remote>:<branch> (where that remote points at the fork) should make the head explicit; a bare branch leaves it to the host checkout's remote.
branch is pushed to both mdx-js/eslint-mdx and JounQin/eslint-mdx
target repo permissions for the host gh identity: push: true
host checkout remotes: origin, upstream; origin points at the fork, and there is no remote named mdx-js
Observed failures:
# bare head
GraphQL: must be a collaborator (createPullRequest)
# origin:fix/list-item-indent
GraphQL: Head sha can't be blank, Base sha can't be blank,
No commits between mdx-js:next and JounQin:fix/list-item-indent
# mdx-js:fix/list-item-indent
error: no remote named "mdx-js" here, so "mdx-js:fix/list-item-indent"
cannot be resolved; this checkout has: origin, upstream
Direct host checks with the same login:
gh api user -> JounQin
repo permissions -> push: true
So the branch exists and the account can push, but the host route still resolves the create request as a non-collaborator. One hypothesis: the host broker process has GH_TOKEN set, which overrides GH_CONFIG_DIR and therefore --as-user <login>; another is that the head repository resolution is still using the fork/current checkout. No tokens or private paths are included here.
GraphQL: must be a collaborator (createPullRequest)
So with origin matching the target repo, the head remote resolution is no longer the differentiator; the request still appears to reach GitHub as an identity without collaborator access. I restored origin to its previous fork URL afterward. No credentials or private paths included.
With origin pointing at mdx-js/eslint-mdx and --head origin:... still failing, the head-resolution hypothesis no longer explains it: the head repository is already explicit. That points at the token/identity gh actually uses, or at the token's permissions, rather than at --head.
Could you run the create directly on the host with the same account environment gcb is supposed to use:
env -u GH_TOKEN -u GITHUB_TOKEN -u GH_ENTERPRISE_TOKEN -u GITHUB_ENTERPRISE_TOKEN \
GH_CONFIG_DIR="$HOME/.config/gh-JounQin" \
GH_HOST=github.com \
gh pr create --repo mdx-js/eslint-mdx \
--head origin:fix/list-item-indent --base next \
--title test --body test
and also, in the host broker's own environment (sanitized):
env | grep '^GH_'||true
GH_CONFIG_DIR="$HOME/.config/gh-JounQin" gh auth status
Two outcomes:
If the direct command fails the same way, the gh-JounQin credential cannot create pull requests. push: true only proves contents write; a fine-grained token can still lack Pull requests: write, and GitHub's GraphQL reports that as must be a collaborator. gh auth status should show the token type/scopes.
If the direct command succeeds but gcb fails, the host broker is injecting a different token (for example an inherited GH_TOKEN that overrides GH_CONFIG_DIR) and I will trace that path.
I reverted the uncommitted head-owner change rather than shipping a fix for a cause the new evidence rules out.
The app-installation limitation is exactly why --as-user <login> routes through gcb host, so this should work without installing the App. I rechecked the repo/branches: mdx-js/eslint-mdx does have next and fix/list-item-indent, so the target branch is real.
With origin changed to the target and --head origin:... still failing, the remaining likely cause is the credential the host gh actually uses, not head resolution. Could you run these on the host with the same config directory the broker selects:
env -u GH_TOKEN -u GITHUB_TOKEN -u GH_ENTERPRISE_TOKEN -u GITHUB_ENTERPRISE_TOKEN \
GH_CONFIG_DIR="$HOME/.config/gh-JounQin" \
GH_HOST=github.com \
gh api user --jq .login
env -u GH_TOKEN -u GITHUB_TOKEN -u GH_ENTERPRISE_TOKEN -u GITHUB_ENTERPRISE_TOKEN \
GH_CONFIG_DIR="$HOME/.config/gh-JounQin" \
GH_HOST=github.com \
gh pr create --repo mdx-js/eslint-mdx \
--head mdx-js:fix/list-item-indent --base next \
--title test --body test
If the first prints a login other than JounQin, GH_CONFIG_DIR is not selecting the account the broker thinks it is. If the second still says must be a collaborator, the gh-JounQin token itself lacks Pull requests: write (a fine-grained token can have contents write and still fail this), or is not SSO-authorized for the org; gh auth status will name the token/scopes. If the second succeeds, the broker is injecting a different environment and I will trace that path.
Please do not paste tokens; login, token type and scopes are enough.
I can verify this from the broker without touching the host shell, and it changes the diagnosis.
Against the same repository via the host route:
gcb gh pr list --repo mdx-js/eslint-mdx --author @me --state all --as-user JounQin
# (empty)
gcb gh pr list --repo mdx-js/eslint-mdx --author JounQin --state all --as-user JounQin
# JounQin's pull requests, including #659, #658, #657, ...
Via the broker person route:
gcb gh pr list --repo mdx-js/eslint-mdx --author @me --state all --as-user
# the same JounQin's pull requests
So the host route really is not running as JounQin, independently of --head and App installation. This is an account-selection bug on the host, not a head-resolution bug.
The candidate is GH_CONFIG_DIR: the host gh is selecting a config directory that does not carry JounQin's token, or the token is being read from a keyring/config that GH_CONFIG_DIR does not isolate. Please run on the host:
GH_CONFIG_DIR="$HOME/.config/gh-JounQin" GH_HOST=github.com gh api user --jq .login
GH_CONFIG_DIR="$HOME/.config/gh-JounQin" GH_HOST=github.com gh auth status
The first must print JounQin; if it does not, ~/.config/gh-JounQin is not the account the broker thinks it is. If it does, the broker's HOME/GH_CONFIG_DIR differs from the shell's, and that is the path I need to fix.
I am not shipping a head change; the host-route evidence rules it out.
Root cause found on the host, and the PR route is working again.
~/.config/gh-JounQin was a symlink to ~/.config/gh (created 2026-11-13 02:14:50). The default config was logged in as i1stG, not JounQin, and i1stG has push: false on mdx-js/eslint-mdx. GH_CONFIG_DIR selected the directory but not the active user, so --as-user JounQin silently ran as i1stG.
Recovery, without switching the default account:
replaced the symlink with a real ~/.config/gh-JounQin
logged JounQin in there once (GH_CONFIG_DIR=~/.config/gh-JounQin gh auth login)
default ~/.config/gh still stays on i1stG
Verified:
GH_CONFIG_DIR=~/.config/gh-JounQin gh api user --jq .login # JounQin# host route @me now returns JounQin's PRs# permissions.push for mdx-js/eslint-mdx is true
I also added a guard in #160: the host broker reads the account directory's hosts.yml and refuses when its active github.com user is not the requested login, instead of acting as the wrong person.
On “why did it change”: the current hosts.yml has only i1stG and was last written 2026-11-11 07:44; the symlink dates from 02:14 today. There is no shell-history record of a logout/switch at that time, so the exact earlier overwrite cannot be reconstructed from what remains. The durable fix is per-account real directories (or gh auth token --user <login> + a per-command GH_TOKEN), never a symlink to the default config.
Do not switch accounts to work around this: gh only has one active account per host, but separate GH_CONFIG_DIR values let each identity coexist.
Activity
git-credential-broker commentedon Nov 12, 2026
Checked the host route: it passes
--headthrough togh pr createunchanged, setsGH_CONFIG_DIR=~/.config/gh-<login>andGH_HOST=github.com, and runs in the checkout/channel it is serving.must be a collaborator (createPullRequest)is about the head repository, not necessarily push access to--repo. With a bare--head <branch>,ghinfers the head repository from the checkout it runs in; if the host broker is serving a different checkout (or the global channel), that can resolve to a repository whereJounQinis not a collaborator, even though--repopush access is fine.To narrow it down, could you share sanitized:
--headvalue (a bare branch or<remote>:<branch>)git remote -vand the current branch in the checkout where the request ranJounQin's forkgh pr create --repo <owner>/<repo> --head <branch> --base next --title ...If the branch is in a fork,
--head <remote>:<branch>(where that remote points at the fork) should make the head explicit; a bare branch leaves it to the host checkout's remote.git-credential-broker commentedon Nov 12, 2026
Sanitized details from the failing case:
--headvalue:fix/list-item-indent(bare branch)mdx-js/eslint-mdxmdx-js/eslint-mdxandJounQin/eslint-mdxghidentity:push: trueorigin,upstream;originpoints at the fork, and there is no remote namedmdx-jsObserved failures:
Direct host checks with the same login:
So the branch exists and the account can push, but the host route still resolves the create request as a non-collaborator. One hypothesis: the host broker process has
GH_TOKENset, which overridesGH_CONFIG_DIRand therefore--as-user <login>; another is that the head repository resolution is still using the fork/current checkout. No tokens or private paths are included here.git-credential-broker commentedon Nov 12, 2026
Follow-up: I changed the host checkout's
originto point atmdx-js/eslint-mdxand retried with a matching head:It still fails with:
So with
originmatching the target repo, the head remote resolution is no longer the differentiator; the request still appears to reach GitHub as an identity without collaborator access. I restoredoriginto its previous fork URL afterward. No credentials or private paths included.git-credential-broker commentedon Nov 12, 2026
With
originpointing atmdx-js/eslint-mdxand--head origin:...still failing, the head-resolution hypothesis no longer explains it: the head repository is already explicit. That points at the token/identityghactually uses, or at the token's permissions, rather than at--head.Could you run the create directly on the host with the same account environment gcb is supposed to use:
and also, in the host broker's own environment (sanitized):
Two outcomes:
gh-JounQincredential cannot create pull requests.push: trueonly proves contents write; a fine-grained token can still lack Pull requests: write, and GitHub's GraphQL reports that asmust be a collaborator.gh auth statusshould show the token type/scopes.GH_TOKENthat overridesGH_CONFIG_DIR) and I will trace that path.I reverted the uncommitted head-owner change rather than shipping a fix for a cause the new evidence rules out.
git-credential-broker commentedon Nov 12, 2026
The app-installation limitation is exactly why
--as-user <login>routes throughgcb host, so this should work without installing the App. I rechecked the repo/branches:mdx-js/eslint-mdxdoes havenextandfix/list-item-indent, so the target branch is real.With
originchanged to the target and--head origin:...still failing, the remaining likely cause is the credential the hostghactually uses, not head resolution. Could you run these on the host with the same config directory the broker selects:If the first prints a login other than
JounQin,GH_CONFIG_DIRis not selecting the account the broker thinks it is. If the second still saysmust be a collaborator, thegh-JounQintoken itself lacks Pull requests: write (a fine-grained token can have contents write and still fail this), or is not SSO-authorized for the org;gh auth statuswill name the token/scopes. If the second succeeds, the broker is injecting a different environment and I will trace that path.Please do not paste tokens; login, token type and scopes are enough.
git-credential-broker commentedon Nov 12, 2026
I can verify this from the broker without touching the host shell, and it changes the diagnosis.
Against the same repository via the host route:
Via the broker person route:
gcb gh pr list --repo mdx-js/eslint-mdx --author @me --state all --as-user # the same JounQin's pull requestsSo the host route really is not running as
JounQin, independently of--headand App installation. This is an account-selection bug on the host, not a head-resolution bug.The candidate is
GH_CONFIG_DIR: the hostghis selecting a config directory that does not carry JounQin's token, or the token is being read from a keyring/config thatGH_CONFIG_DIRdoes not isolate. Please run on the host:The first must print
JounQin; if it does not,~/.config/gh-JounQinis not the account the broker thinks it is. If it does, the broker'sHOME/GH_CONFIG_DIRdiffers from the shell's, and that is the path I need to fix.I am not shipping a head change; the host-route evidence rules it out.
git-credential-broker commentedon Nov 12, 2026
Root cause found on the host, and the PR route is working again.
~/.config/gh-JounQinwas a symlink to~/.config/gh(created 2026-11-13 02:14:50). The default config was logged in as i1stG, not JounQin, and i1stG haspush: falseonmdx-js/eslint-mdx.GH_CONFIG_DIRselected the directory but not the active user, so--as-user JounQinsilently ran as i1stG.Recovery, without switching the default account:
~/.config/gh-JounQinGH_CONFIG_DIR=~/.config/gh-JounQin gh auth login)~/.config/ghstill stays on i1stGVerified:
Then the original command opened:
mdx-js/eslint-mdx#660
I also added a guard in #160: the host broker reads the account directory's
hosts.ymland refuses when its active github.com user is not the requested login, instead of acting as the wrong person.On “why did it change”: the current
hosts.ymlhas only i1stG and was last written 2026-11-11 07:44; the symlink dates from 02:14 today. There is no shell-history record of a logout/switch at that time, so the exact earlier overwrite cannot be reconstructed from what remains. The durable fix is per-account real directories (orgh auth token --user <login>+ a per-commandGH_TOKEN), never a symlink to the default config.Do not switch accounts to work around this: gh only has one active account per host, but separate
GH_CONFIG_DIRvalues let each identity coexist.