FeaturesApprovals and push
Reject
Reject a push request. You can make a new request after rejecting
Reject a commit that must not be sent out. It needs the same sessions:approve as approving. A session has only one open request, so if something needs fixing, reject, send the session its next message, and then make a new request. Use the session from Request (sessionId in the SDK, SID in the HTTP API). Since the earlier request has ended, make a new one.
Reject
const second = await werft.sessions.pushRequests.create(sessionId);
const rejected = await werft.sessions.pushRequests.reject(sessionId, second.id, {
git_commit: second.git_commit,
reason: "needs tests first",
});
console.log(rejected.state, rejected.resolution_reason);rejected needs tests firstreason is optional. A rejection does not check whether the commit changed.
Approve or reject once
Approving or rejecting a request that was already approved or rejected is 409 PUSH_REQUEST_RESOLVED. That attempt is also kept as a receipt.
import { isApiError } from "@werft-ai/sdk";
try {
await werft.sessions.pushRequests.approve(sessionId, second.id, {
git_commit: second.git_commit,
});
} catch (error) {
if (!isApiError(error, "PUSH_REQUEST_RESOLVED")) throw error;
console.log(error.code);
const receiptId = (error.details as { receipt_id?: string } | null)?.receipt_id;
if (receiptId) {
const receipt = await werft.receipts.get(receiptId);
const result = receipt.result as { refusal?: string | null } | null;
console.log(receipt.operation, receipt.status, result?.refusal);
}
}PUSH_REQUEST_RESOLVED
resolve_push failed already_resolvedNext steps
- receipt: read the record of the request, the approval or rejection, and the push