fj pr ready reports success without clearing the draft state #268

Open
opened 2026-09-11 04:00:25 +00:00 by stephen · 0 comments
Owner

fj pr ready reports success and leaves the pull request a draft.

api::pull_core::ready PATCHes /repos/{owner}/{repo}/pulls/{number} with {"draft": false}. Forgejo decodes the body, ignores the property, and answers 201 Created, so the command exits 0 having changed nothing.

The comment on it ("PATCH with { "draft": false } works on 7.x") does not hold. Forgejo has no draft column and no draft endpoint: PullRequest.draft is computed on every read by HasWorkInProgressPrefix, a case-insensitive prefix match of the title against repository.pull-request.WORK_IN_PROGRESS_PREFIXES. EditPullRequestOption carries no Draft field in modules/structs/pull.go at either v15.0.2 or v16.0.3, and EditPullRequest in routers/api/v1/repo/pull.go reads none.

Verified against a live 16.0.3 instance:

PATCH body HTTP draft after
{"draft": false} 201 true
{"title": "<prefix stripped>"} 201 false

Fix

PATCH the title with the work-in-progress prefix removed, matched the way the server matches it: anchored at the start, case-insensitive, no leading-whitespace tolerance.

Two cases must fail loudly rather than silently, because the prefix list is instance-configurable and no API exposes it:

  • the title carries no prefix fj recognises (a custom WORK_IN_PROGRESS_PREFIXES), so there is nothing to strip
  • the title is nothing but the prefix, so stripping leaves an empty title the server rejects

fj stack sync --ready goes through the same ready() and inherits the bug.

Fjord had the identical defect and the identical belief, from the same source: the vendored contract's EditPullRequestOption.draft was hand-added to the spec on that assumption (forgejo-api-contract#3) and is dropped by the 16.0.3 re-vendor (forgejo-api-contract#5). The iOS fix is rasterstate/fjord-ios#1276, including the prefix-matching rule and its tests, if it is useful to mirror.

`fj pr ready` reports success and leaves the pull request a draft. `api::pull_core::ready` PATCHes `/repos/{owner}/{repo}/pulls/{number}` with `{"draft": false}`. Forgejo decodes the body, ignores the property, and answers `201 Created`, so the command exits 0 having changed nothing. The comment on it ("PATCH with `{ "draft": false }` works on 7.x") does not hold. Forgejo has no draft column and no draft endpoint: `PullRequest.draft` is computed on every read by `HasWorkInProgressPrefix`, a case-insensitive prefix match of the title against `repository.pull-request.WORK_IN_PROGRESS_PREFIXES`. `EditPullRequestOption` carries no `Draft` field in `modules/structs/pull.go` at either `v15.0.2` or `v16.0.3`, and `EditPullRequest` in `routers/api/v1/repo/pull.go` reads none. Verified against a live 16.0.3 instance: | PATCH body | HTTP | `draft` after | |---|---|---| | `{"draft": false}` | 201 | `true` | | `{"title": "<prefix stripped>"}` | 201 | `false` | ### Fix PATCH the title with the work-in-progress prefix removed, matched the way the server matches it: anchored at the start, case-insensitive, no leading-whitespace tolerance. Two cases must fail loudly rather than silently, because the prefix list is instance-configurable and no API exposes it: - the title carries no prefix `fj` recognises (a custom `WORK_IN_PROGRESS_PREFIXES`), so there is nothing to strip - the title is nothing but the prefix, so stripping leaves an empty title the server rejects `fj stack sync --ready` goes through the same `ready()` and inherits the bug. Fjord had the identical defect and the identical belief, from the same source: the vendored contract's `EditPullRequestOption.draft` was hand-added to the spec on that assumption (forgejo-api-contract#3) and is dropped by the 16.0.3 re-vendor (forgejo-api-contract#5). The iOS fix is rasterstate/fjord-ios#1276, including the prefix-matching rule and its tests, if it is useful to mirror.
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
rasterstate/fj#268
No description provided.