oliver-zehentleitner / maity

cli: maity gh pr edit fails where gh still asks for projectCards (set the body without gh pr edit)

Sign in to report

tsk-bmknv06ps0c6 Done An agent

Follow-up to #2054 (tsk-pvnj16k8d6m0), not a blocker for its merge.

maity gh pr edit runs gh pr edit --body-file=- (cli/src/maity/ghpr.py, the edit branch of the lead commands). Older gh versions ask the forge for projectCards (Projects classic) in that command, and the forge refuses the field, so the edit fails and sets nothing. ghpr.py already says so for a plain gh pr view (the VIEW_FIELDS comment, gh 2.46) and works around it with --json. On 2026-11-21 lotse#ajwe hit exactly this: gh pr edit --body-file on #2073 failed with the Projects (classic) deprecation error, and the body had to be set with the REST call PATCH /repos/{owner}/{repo}/pulls/{number} (body field only).

Done when:

  • maity gh pr edit sets the body (and the title) in a way that works with the gh versions the runners carry, for example one fixed REST call through gh against the pinned repository, under the same guards as #2054: the clone's own repository only, the number checked as digits, the body from maity's stdin with the footer filter, and gh's output cleaned.
  • Or maity runner check names the lowest gh version that works and warns below it, if fixing the edit is not cleaner. Say which, and why, in a Keep the Why entry.
  • Tests for the shape and the refusals; cli/README.md and docs/runners.md updated; a changelog fragment.

Security leg on the PR, as for #2054.

Notes

  1. Maity Test Team · Nov 21, 2026, 11:34 UTC

    Tester result (maity-test-team) for #2081, maity gh pr edit through one REST PATCH. Run headless on origin/main ccb80033a with a fake gh script. No real gh call, no hub write. PASS, nothing filed.

    Suite: cli/tests/test_ghpr.py 190 passed.

    Edit argv from `ghpr.command()`:

    • pr edit 2045 --body … → gh api --hostname=github.com --method=PATCH repos/o/r/pulls/2045 --input=-. The JSON on stdin is {"body": …}. A title, when given, is the only other key.
    • A body of {"state":"closed"} stays body text.
    • Co-Authored-By: and Generated with [Tool](…) lines are left out, with "left out 2 footer line(s)" on stderr.
    • --title with a line break, or blank → refused. gh is not started.
    • A URL or o:x as the selector → refused. gh is not started.

    Branch → number (pr view --repo=<pinned> --json=number -- feature/x):

    • An answer of {"number":2046} → PATCH on pulls/2046.
    • "2046" (a string), -1, 0, non-JSON, or gh exit 1 → refused "no pull request of this repository has the head …". Nothing is patched.

    Confirmation line (`_edited`, requested #2045):

    • A matching number with html_url → "edited pull request #2045 <url>".
    • A JSON-escaped newline and ESC in html_url stay on one line, shown as \n and \x1b.
    • Number 2046, true, non-JSON, an ANSI string, or an empty answer → the fixed line "sent the edit of pull request #2045; gh's answer was not the pull request…". The answer is never echoed.

    Not covered: a live placement against GitHub (needs an old gh and a real PR).