Skip to content
中文

Open a change's pull request

Code Mode: praxis.devops.changes.openPullRequest

HTTP: POST /devops/v1/changes/{id}:openPullRequest

Open the pull request for a change: its branch into the project’s default branch, opened by DevOps’s own GitHub App. A cloud workspace holds no GitHub credential, so this is how work pushed with the unit push becomes a pull request; praxis devops change pr calls it from the workspace. Push first: a branch with no commits beyond the default branch is refused with PULL_REQUEST_REFUSED and GitHub’s words. A branch that already has an open pull request answers that one with created=false, so calling again is safe; when the call passes a title or a body, those fields are written onto that pull request (GitHub PATCH /pulls/{number}) and the answer says updated=true, while a field not passed is left as it is — which is how a wrong or missing description is corrected, and how the merge gate’s exposure-declared check is re-evaluated from the new body. Only an open pull request can be rewritten: once it is merged or closed its head branch is usually deleted with it, so a call that names a title or a body is refused with PULL_REQUEST_NOT_OPEN, naming that pull request and the branch, instead of trying to open a second one. The pull request then appears on the change and runs its merge gate as usual. For a later slice opened with slices.create, pass head set to that slice’s branch (<id>—<n>): the pull request is opened from it instead of the change’s own branch, and a branch that belongs to another change is refused with INVALID_ARGUMENT. The id is the branch name; give it as it comes back (fix/expired-links) — the SDK and the CLI encode the slash themselves, and only a hand-written HTTP request sends fix%2Fexpired-links.

Signature

praxis.devops.changes.openPullRequest(args:{path:{/** e.g. "feat/run-page-v2" */ id:string};body?:{/** The pull request's title; defaults to the change's title. e.g. "fix(file): expired upload links answer 410" */ title?:string;/** The pull request's description, markdown. */ body?:string;/** Open it as a draft. e.g. false */ draft?:boolean;/** The branch the pull request is opened from, for a later slice of the change: <change id>--<n>, as `slices.create` answered it; omit it for the change's own bran e.g. "fix/expired-links--2" */ head?:string}}):Promise<{/** The pull request's platform id (pr_…), which retrieve, rerunGate, merge and recordVerdict address. e.g. "pr_01JQ8Z3M9K4V7B2N6C5X0YTRHW" */ id?:string;/** The pull request's number on the git host. e.g. 4465 */ number:number;/** Where the pull request is on the git host. e.g. "https://github.com/acme/app/pull/4465" */ htmlUrl:string;/** True when this call opened it; false when the branch already had this open pull request. e.g. true */ created:boolean;/** True when this call rewrote the title and/or body of the pull request that was already open; false when it opened one or left the open one unchanged. e.g. false */ updated:boolean}>;

Parameters

NameInTypeRequiredDescription
idpathstringyesThe change’s id, which is its branch name <type>/<slug> from a change list or create answer. Give it as it comes back — `feat/run-page-v2`: the SDK and the CLI encode the slash themselves, and an id that is already percent-encoded is encoded a second time and answers CHANGE_NOT_FOUND. Only a caller writing the HTTP request by hand sends feat%2Frun-page-v2.

Request body

RequiredContent typesDescription
noapplication/json

Responses

StatusContent typesDescription
200application/jsonThe pull request for the change’s branch: its id, number, link, whether this call opened it, and whether it rewrote an already open one.
400application/jsonINVALID_PARAMS or INVALID_ARGUMENT means a field, query value or identifier violates the documented format or range — an unknown enum value, a pageSize outside 1..100, an unsupported filter or orderBy field, or an id with the wrong prefix. Correct the named input; nothing was read or written.
401application/jsonThe API key is missing or invalid; send a valid Praxis API key in the Authorization header before retrying.
403application/jsonThe credential carries no organization, or that organization cannot reach this project; use a key belonging to the project’s organization. No cross-organization read is possible.
404application/jsonCHANGE_NOT_FOUND means no change with that id exists in this organization; list the project’s changes and use an id from that answer, with its slash percent-encoded.
409application/jsonPULL_REQUEST_REFUSED when GitHub would not open it and the head has no pull request at all (most often nothing has been pushed yet); the message carries GitHub’s words. PULL_REQUEST_NOT_OPEN when the head’s pull request is merged or closed — a description written for a pull request that already landed — with that pull request’s number, its state and the branch in the message.
500application/jsonINTERNAL means the service could not complete the request; retry once, and if it repeats report the request id. A read is safe to repeat; a write that failed this way should be re-read before it is sent again.