tinyhumansai/openhuman · error · Error

gh issue comment failed: ${r.stderr?.trim() || ""}

Error message

gh issue comment failed: ${r.stderr?.trim() || ""}

What it means

postOrUpdateTrackingComment() in scripts/agent-batch/status.mjs posts a brand-new tracking comment via `gh issue comment <N> --repo <repo> --body-file -` (body piped on stdin) and throws with gh's stderr when the child exits non-zero. This branch only runs when the earlier gh api comment listing found zero comments containing the batch marker — i.e. the first --post for this batch.

Source

Thrown at scripts/agent-batch/status.mjs:160

    .map((line) => line.trim())
    .filter((line) => line.length > 0)
    .map((line) => JSON.parse(line));
  if (existing.length === 0) {
    const r = spawnSync(
      "gh",
      [
        "issue",
        "comment",
        String(issue),
        "--repo",
        spec.base_repo,
        "--body-file",
        "-",
      ],
      { encoding: "utf8", input: body },
    );
    if (r.status !== 0) {
      throw new Error(`gh issue comment failed: ${r.stderr?.trim() || ""}`);
    }
    process.stdout.write(
      `[agent-batch] posted new tracking comment on #${issue}\n`,
    );
  } else {
    const id = existing[0].id;
    // Pass the comment body via stdin (-F body=@-) rather than a command-line
    // arg. Long markdown tables can grow large and -f body=${body} risks
    // hitting OS argv length limits (ARG_MAX).
    const r = spawnSync(
      "gh",
      [
        "api",
        "--method",
        "PATCH",
        `repos/${spec.base_repo}/issues/comments/${id}`,
        "-F",
        "body=@-",

View on GitHub (pinned to a221052e0d)

Solutions

  1. Test permission directly: `gh issue comment <N> --repo tinyhumansai/openhuman --body "probe"` (delete after)
  2. Ensure the token has issues:write (fine-grained) or `public_repo`/`repo` scope (classic); re-auth if needed
  3. Confirm the tracking issue is unlocked and open for collaborators
  4. Re-run the command once the permission/rate-limit issue is cleared — the listing step will still find no marker comment, so it will retry the post path

Example fix

# before
$ node scripts/agent-batch/status.mjs batch.json --post
Error: gh issue comment failed: HTTP 403: Resource not accessible by integration

# after (token with issues:write)
$ export GH_TOKEN=<token-with-issue-comment-scope>
$ node scripts/agent-batch/status.mjs batch.json --post
Defensive patterns

Strategy: retry

Validate before calling

import { spawnSync } from "node:child_process";
const who = spawnSync("gh", ["api", "user", "--jq", ".login"], { encoding: "utf8" });
if (who.status !== 0) throw new Error("gh token invalid");
const perm = spawnSync("gh", ["api", `repos/tinyhumansai/openhuman/collaborators/${who.stdout.trim()}/permission`, "--jq", ".permission"], { encoding: "utf8" });
if (!["write", "admin"].includes(perm.stdout.trim())) throw new Error("token cannot comment on the tracking issue");

Try / catch

try {
  await postComment(spec, body);
} catch (e) {
  if (/gh issue comment failed/.test(e.message) && !/40[13]/.test(e.message)) {
    await sleep(10_000);
    return postComment(spec, body);
  }
  throw e;
}

Prevention

When it happens

Trigger: First --post run for a batch when: the account has no write/comment permission on tinyhumansai/openhuman (403/404), the tracking issue is locked, the token is read-only (classic read PAT or fine-grained without issues:write), or the network/rate limit rejects the POST.

Common situations: Contributors running the batch status tooling from forks with tokens that can read but not comment; locked/archived tracking issues; intermittent secondary rate limits when several batch agents post near-simultaneously.

Related errors


AI-assisted analysis of tinyhumansai/openhuman@a221052e0d (2026-08-16). Data as JSON: /api/errors/f65248e802e85c35. Report an issue: GitHub.