Repository navigation
feat(bitbucket): add guarded cloud issue comment create - #1078
Conversation
|
Hi @potiuk , I opened the next Bitbucket follow-up for #606. This is the first narrowly scoped write path: magpie-bitbucket issue comment <id> --body-file <path>It follows the existing Magpie/Jira write discipline: explicit user confirmation stays in the calling skill, while the bridge only executes the already-confirmed mutation. Scope is Cloud-only; Data Center native issue-comment writes remain explicitly unsupported with linked Jira guidance. Missing/empty body files fail before any outbound write, and write requests reuse the existing auth/HTTPS protections while refusing redirects. Focused/full pytest, ruff, mypy, |
potiuk
left a comment
There was a problem hiding this comment.
Approving. This is the first write operation in the Bitbucket bridge, so I
reviewed the mutation path rather than the feature, and it holds up — worth
recording what I actually checked.
The security properties are real, not just claimed:
post_jsoncalls_require_https(url)before building the request.- Redirects are genuinely rejected, not followed:
NoAuthRedirectHandler.redirect_requestraises unconditionally, so the
comment "Writes never follow redirects: repeating a mutation at a
redirected location is less safe than failing" is accurate. It is also the
stricter of the two handlers available —get_textuses
SameHostRedirectHandler,get_jsonuses this one — and picking the
stricter one for a mutation is the right call. A side effect worth noting:
that error is raised from insideopener.open, which makes the
except BitbucketError: raiseclause load-bearing rather than decorative. - No path-injection surface:
quote_pathis
urllib.parse.quote(value, safe=""), so it escapes/as well — an
issue_idof../../adminbecomes..%2F..%2Fadmin. It is applied to
workspace, repo slug, and issue id. --body-filewith no inline--bodyalternative matches the framework's
own body-file discipline and keeps contributor-authored text away from
shell escaping.- Data Center raises explicitly instead of silently no-opping, matching
the existingget_issue_commentspattern in that module. - I specifically checked whether an unexpected response shape could report
ok: falseon a write that actually succeeded — which would invite a
double-post on retry. It cannot:_cloud_issue_commentreturns an
eleven-key dict literal, so it is never falsy.
The tests are better than typical for a write path. Beyond asserting URL,
method, content type and exact payload, the failure cases use
mock_create_issue_comment.assert_not_called() — proving the mutation is not
attempted when the body file is empty or missing, rather than only that an
error surfaces. That is the assertion that matters here.
Bookkeeping is right too. labels-and-capabilities.md moves the tool
from partial-read-only to partial and corrects the qualifier's own
explanatory sentence — dropping "read-only" from what the qualifier means is
easy to miss. adapters.md is updated in the same PR per the spec-sync rule
and now states the HITL boundary explicitly.
One nit, for a follow-up rather than this PR
tools/bitbucket/tests/test_bitbucket.py has four thorough
SameHostRedirectHandler tests and none for NoAuthRedirectHandler, which
is now the guard on a mutation path. The behaviour is correct by
construction, and the gap is pre-existing — get_json already used that
handler — so this PR inherits it rather than introduces it. But "a write is
never replayed at a redirect target" is now a stated security property of
this bridge, and a one-line test would pin it. Not worth holding the merge.
Keeping the scope this small for the first write was the right instinct.
This review was drafted by an AI-assisted tool and
confirmed by a Magpie maintainer. The maintainer
approving this PR has read the findings and signed off. If
something feels off, please reply on the PR and a maintainer
will follow up.More on how Magpie handles maintainer review:
CONTRIBUTING.md.
Summary
magpie-bitbucket issue comment <id> --body-file <path>for creating Bitbucket Cloud issue comments.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
prek run --all-filespassesPYTHONPATH=src uv run --group dev pytest tests/test_bitbucket.py -quv run --group dev ruff check src tests --fixuv run --group dev ruff format src testsuv run --group dev mypy src tests(
PYTHONPATH=tools/skill-evals/src python3 -m skill_evals.runner tools/skill-evals/evals/<skill>/)(a regression test for the bug fixed / the behaviour added — see CONTRIBUTING.md)
git diff --checkis cleanRFC-AI-0004 compliance
contract:trackeror backend parityLinked issues
Refs #606
Notes for reviewers
This is the first write operation in the Bitbucket bridge and intentionally keeps the scope small.
The new command is:
The write path follows the same discipline documented by the existing Jira bridge: the bridge executes the mutation, but confirmation is owned by the calling skill. There is deliberately no bridge-level
--confirmflag.Implementation details:
POSTto the issue comments endpoint--body-fileTests cover the Cloud POST request/body, Data Center rejection, response normalization, CLI success, and missing/empty body failures before the mutation path is invoked.
All broader writes — issue updates, PR comments/reviews, task mutation, decline/merge, branch changes, and build mutations — remain out of scope for this PR.