Repository navigation
fix(protocol): don't read a 403 body as the agent's login - #101
Open
glennfaison wants to merge 1 commit into
Open
glennfaison wants to merge 1 commit into
glennfaison wants to merge 1 commit into
Conversation
For a GitHub App installation token `gh api user` is a 403, and `gh` still prints the error body on stdout. `_agent_self` took that body as the agent's login, and `_trusted_logins` split it into the trusted authors. `_agent_self` now uses the output only when the call succeeds and it is a login (`name` or `name[bot]`). The protocol says how to check that `gh` works without `gh auth status` or `gh api user`, and that a trusted_authors login is matched whole, so `*` matches nothing.
1 of 6 tasks
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.
Found by running
/retrospectiveover the last 14 days of a downstream repo's run log (glennfaison/livepage, Nov 1–15, 143 entries).Problem
A runner using a GitHub App installation token logged
gh auth status/gh api userfailures in 39 of 69 problem entries, and 12 entries traced to trust going wrong. For such a tokengh api useris a 403 ("Resource not accessible by integration"), andghstill prints the error body on stdout._agent_selfcaptured that body, and_trusted_loginssplit it on commas into the trusted-author list. Agents reported exactly this ("_agent_selfcaptured an error JSON"). Downstream it led to ready handoffs posted and then reverted, and duplicate PRs claiming one issue.Separately, agents had no guidance on how to check
gh, so they rangh auth statusthemselves, read the App-token failure as "invalid token", and logged it as a problem on almost every Triaging run. Reads and writes worked the whole time: the same bot wrote 126 log comments in the window.Change
lib.sh_agent_self: use the output ofgh api useronly when the call succeeded and it is a login (nameorname[bot]); otherwise the agent is unknown.ghworks (gh repo view), why notgh auth status/gh api user, and that a 401/403 on an actual write is afailedproblem.trusted_authorslogin is matched whole, as the API shows it (my-app[bot], notmy-app),*matches nothing, and an agent whosegh api useris a 403 must be listed. The downstream runner passedkilo-code-bot,…,*, which trusted nobody.Tests
New
Agent identitysection intests/lib.test.sh. Realghprints the 403 body on stdout, which the simulator'sfaultsdo not (they write to stderr only), so the tests put aghfunction in front of the simulator. Before the fix 4 of the 8 new checks failed, with the error JSON inside the trusted logins; all pass after.npm run checkis green (lint, validate, plugin version, 561 tests), and the pre-push hook ran it.Not in this PR
setup-github-agent-workflowstep 1 still saysgh auth statusmust succeed. A human runs setup once, but an App token would fail it. Changing it touches the skill's contract and the simulator surface, so I left it for a follow-up.trusted_authorsis not added. The trust list stays exact logins.