nikivdev/code · error
`gh secret set {}` failed
Error message
`gh secret set {}` failed What it means
gh_secret_set invokes `gh secret set <name>` (optionally piping the secret value via stdin) and bails if the child process exits non-zero. This means GitHub CLI failed to create/update the named Actions secret in the target repo.
Source
Thrown at src/release_signing.rs:254
// Avoid passing secrets via argv (ps); `gh secret set` reads from stdin when --body is omitted.
let mut child = cmd
.stdin(Stdio::piped())
.stdout(Stdio::null())
.spawn()
.with_context(|| format!("failed to spawn `gh secret set {}`", name))?;
{
let stdin = child
.stdin
.as_mut()
.context("failed to open stdin for gh")?;
stdin.write_all(value.as_bytes())?;
}
let status = child.wait()?;
if !status.success() {
bail!("`gh secret set {}` failed", name);
}
Ok(())
}
View on GitHub (pinned to a747e741ae)
Solutions
- Run `gh auth status` and `gh auth login` / refresh token with admin:repo (repo scope)
- Set the repo explicitly: `f release signing sync --repo owner/repo` or check the detected repo
- Run `gh secret set NAME -R owner/repo` manually to see the real error
- Verify you have admin access to the repository
Example fix
// before (unauthenticated) f release signing sync // after gh auth login f release signing sync
Defensive patterns
Strategy: try-catch
Validate before calling
// preflight: auth and repo admin access gh auth status || gh auth login gh repo view --json viewerPermission # expect ADMIN or MAINTAIN
Try / catch
try {
run(["f", "release", "signing", "sync", "--repo", "owner/repo"]);
} catch (e) {
if (/gh secret set \S+ failed/.test(String(e))) {
console.error("Check `gh auth status`, repo permissions, and pass the correct --repo.");
} else throw e;
} Prevention
- Run `gh auth login` and keep the token fresh with repo scope
- Always pin the target repo explicitly with --repo to avoid detection mistakes
- Confirm admin/maintain permission on the repo before syncing secrets
When it happens
Trigger: `gh secret set` exits non-zero while `f release signing sync` pushes signing keys to GitHub secrets.
Common situations: Not authenticated or token lacks repo admin scope (`gh auth login` missing / expired); wrong --repo value or repo not found; pushing to an org repo without secrets permission; network/API failure.
Related errors
- gh {} failed: {}
- `gh` is installed but not working
- native session bridge warm command failed with status {}
- pbcopy exited with status {}
- clipboard command exited with status {}
AI-assisted analysis of nikivdev/code@a747e741ae (2026-09-01).
Data as JSON: /api/errors/b68f8926ace77b64.
Report an issue: GitHub.