Repository navigation
fix(check): read environment names one per line, and address them encoded - #879
Merged
Merged
Conversation
A name is one path segment, and GitHub admits `/` in one. The three URLs that interpolated the name raw addressed a path that 404s, which is the same `returncode != 0` the split above produced — the whole credential check returns skipped-for-want-of-admin, for every environment. So splitlines() alone only fixed half of it: the name now survives the read and is lost on the way back out. Verified on a live repo: an environment named `a/b probe` lists under that name, its `/secrets` path interpolated raw exits 1 with 404, and the percent-encoded path resolves.
max-sixty
pushed a commit
to max-sixty/worktrunk
that referenced
this pull request
Aug 13, 2026
Automated nightly regeneration of tend's workflow files. **tend version:** 0.1.14 → 0.1.15 **Notable changes** - **Rate-limit handling**: a maintainer can approve past the spike limit (max-sixty/tend#874), and `tend-mention` now skips comments on `tend-rate-limit`-labelled issues as well as `tend-outage` ones — the same self-trigger loop guard, widened to every issue tend files about its own health. - **Review flow**: a push is queued behind an examined-HEAD gate instead of cancelling the in-flight review (max-sixty/tend#903), the review is submitted before a fix is pushed (max-sixty/tend#834), a force-push triggers a re-review rather than trusting the re-anchored SHA (max-sixty/tend#884), and the `/code-review` second pass is unconditional (max-sixty/tend#937). - **CI monitoring**: both the check poll and the `gh run rerun --failed` poll now end terminally when the cap is hit instead of reading as done (max-sixty/tend#876, max-sixty/tend#951), and a failed GitHub-status probe no longer reads as "no incident" (max-sixty/tend#913). - **Nightly**: conflicted bot PRs are test-merged locally instead of filtered on the lazy `mergeable` field (max-sixty/tend#898), and mention runs skip the bot's own review and a third party's content-free approval (max-sixty/tend#916, max-sixty/tend#955). - **`tend check`**: an unreadable ruleset bypass list is reported as unknown rather than ungated (max-sixty/tend#825), environment names are read one per line and addressed encoded (max-sixty/tend#879), and `credential-environments` no longer points at the setting it rejects (max-sixty/tend#900) — this repo currently `SKIP`s that check, so its wording should improve here. Full comparison: max-sixty/tend@0.1.14...0.1.15 Co-authored-by: worktrunk-bot <[email protected]>
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.
check_credential_environmentsread the environment list withlisted.stdout.split()and interpolated each name straight into the API path. GitHub admits both a space and a/in an environment name, and the list endpoint returns one name per line — so an environment calledstaging deploybecame two names,staginganddeploy, that exist nowhere, and one calleda/baddressedrepos/<r>/environments/a/b/secrets, a path that names no environment either.Both shapes 404. The first 404 is the
secrets is None or secrets.returncode != 0branch, which returns the whole check as skipped:So the check that backs the security model's "a run the bot can cause reaches no credential" claim stops verifying, and the message blames the token rather than naming the real cause. The genuine environment is never examined either — if it holds an ungated credential, nothing reports it. One such environment costs the repo the check entirely, including for its other environments.
splitlines()fixes the read._env_path—quote(name, safe="")— fixes the way back out:gh apipercent-encodes a space itself but passes a/through as a path separator, and it does not re-encode the escapes it is handed, so encoding the whole name as one segment covers both shapes with one rule.Verification
Confirmed against live GitHub on
tend-agent/tend-integration, with both probe environments deleted afterwards:The escapes survive the PUT, which is what shows
ghpasses them through rather than re-encoding the%.%2Fthen resolves on the detail, secrets, and deployment-branch-policies endpoints alike, where the raw/404s. The last of those was read withcustom_branch_policiesenabled — that endpoint 404s on an environment with a nulldeployment_branch_policyregardless of encoding, which is the case_policy_gatereturns on before it ever calls_branch_policies.Tests
test_credential_environments_reads_a_name_containing_a_spaceandtest_credential_environments_reads_a_name_containing_a_slashboth fail with the symptom above when the fix is reverted:The shared
_credential_env_ghfake now matches the percent-encoded segment, as GitHub answers, so a caller that interpolates a name raw stops matching and falls to the same skipped-for-want-of-admin return. Full generator suite: 353 passed.Scope
Deliberately narrow. The other
.split()calls in this file are safe on their inputs —_tags_admin_gatedsplits numeric ruleset ids, and secret names are[A-Z0-9_]— so they are left alone rather than swept. Every other environment name reaching an API path in this file is theTEND_ENVIRONMENTconstant.Found by the nightly survey (bucket 8/28,
generator/src/tend/checks.py). Independent of the other two openchecks.pyPRs (#825, #826), which both concern_bypass_actors_above_bot.