Repository navigation
feat(bitbucket): add guarded cloud PR comment create - #1142
Conversation
|
Hi @potiuk, this continues the guarded Bitbucket write rollout after #1078. This adds one narrow mutation: top-level Bitbucket Cloud PR comment creation via It deliberately reuses the existing write-path protections from issue-comment creation: caller-side confirmation, body-file-only input, HTTPS enforcement, redirect rejection, and quoted path segments. Data Center PR comment writes remain explicitly unsupported in this PR. Tests cover the POST request/body, normalization, CLI success, Data Center rejection, and missing/empty body failures before any write occurs. |
potiuk
left a comment
There was a problem hiding this comment.
This is the one PR in my current batch that adds an outbound write, so I weighted the review toward the gate rather than the plumbing. The gate holds up.
What I verified beyond CI:
_read_body_fileraises before_dispatchever reachesbackend.create_pull_request_comment, and both guard tests assertassert_not_called()on the network function. The empty-body case uses" "rather than an empty string, so whitespace-only bodies are covered too — that is the right level of paranoia for a write path.- Data Center fails closed, raising rather than no-op'ing or falling through to a Cloud URL.
quote_pathis applied to workspace, repo slug, and the caller-supplied pull-request id.- 136 tests pass at this head;
ruff check,ruff format --checkandmypyare all clean. created_pull_request_commentmirrors the existingcreated_issue_commentprecedent exactly — sameoksemantics, samerawpassthrough, same backend naming. Matching the established shape is the right call for a bridge.- The capability-table row is honest about scope ("Partial write, Cloud only"), and the follow-up list correctly drops PR comment creation now that it exists.
HITL discipline is preserved: the bridge executes an already-confirmed action and the README puts the confirmation caller-side, consistent with the existing issue comment command.
One minor inline note about a comment block that ended up documenting the wrong function. I am resolving it so it does not block the merge.
Separately, and explicitly not something for you to fix here: docs/vendor-neutrality.md still describes this bridge as partial-read-only in two places. That was already inaccurate before this PR, since Cloud issue-comment writes pre-date it. Pre-existing drift that deserves its own pass.
🤖 This review was drafted by an AI-assisted tool and may contain mistakes. It has been reviewed and confirmed by an Apache Magpie maintainer before submission. See CONTRIBUTING.md for what this project considers a maintainer review.
Summary
magpie-bitbucket pr comment <id> --body-file <path>for creating a top-level Bitbucket Cloud pull-request comment.Type of change
.claude/skills/<name>/) — eval fixtures updated belowtools/<system>/*.md)tools/*/withpyproject.toml)docs/,README.md,CONTRIBUTING.md)projects/_template/)prek, workflows, validators)Test plan
For Python packages touched: full Bitbucket pytest suite passes
ruff check src testspassesruff format --check src testspassesmypy src testspassesgit diff --checkpassesFocused PR-comment tests cover:
prek run --all-filespassesFor Groovy bridges touched: command-line invocation tested end-to-end
For skill changes: eval suite passes for the affected skill
For skill behaviour changes: a new or updated eval fixture is included
RFC-AI-0004 compliance
Linked issues
Refs #606
Follow-up to #1078
Notes for reviewers
This is the next narrowly scoped Bitbucket write after Cloud issue-comment creation.
The new command is:
Implementation details:
--body-filepost_json(), including HTTPS enforcement and redirect rejectionOut of scope for this PR: inline comments, comment edits/deletion, PR task mutation, review submission, approve/unapprove, decline, merge, PR creation/editing, issue mutation, or build mutation.