feat(bitbucket): add read-only PR discussion fetch#766
Conversation
|
Hi @potiuk I opened the next Bitbucket follow-up PR for the read-only This adds I also tightened the normalised output to match the discussion contract shape more closely: top-level After a local review pass, I also added guarded Cloud pagination so response-controlled
|
|
I ran the review skill over this - looks like there one thing that needs to be fixed: Robustness / API correctness — tools/bitbucket/src/magpie_bitbucket/datacenter.py get_pull_request_discussion: the DC while True loop has no guard against a non-advancing cursor. If /activities returns isLastPage: false with a nextPageStart that never increases, it re-requests the same ?start=N forever. The Cloud path in this same PR added seen_urls repeat-detection for exactly this; the DC path has no analog. Suggest a next_start <= start → break/raise guard to keep the two backends symmetric. Docs / code quality — tools/spec-loop/specs/adapters.md: the new security note was wedged mid-sentence, so the bullet now reads "tools/bitbucket/ Fetched Bitbucket descriptions… before model use. currently provides read-only repository metadata…". Split it into its own sentence/bullet after the coverage description. Minor (non-blocking) — normalize.py: _cloud_inline and _datacenter_inline are near-identical copy-paste (DC only adds a line fallback); a shared helper would remove the duplication. Everything else checks out against the surrounding code: the _datacenter_user fallback, empty-raw-body preservation, the COMMENTED action filter, and the Cloud host/scheme + repeat-URL guards. This review was AI-generated so usual caution apply. |
4598c8a to
fc76553
Compare
|
@justinmclean Thanks, fixed both required points. I added a Data Center pagination guard for get_pull_request_discussion so a non-advancing nextPageStart cannot loop forever, and added a regression test covering that case. I also cleaned up the tools/spec-loop/specs/adapters.md Bitbucket note so the external-data/privacy warning is its own bullet instead of being wedged into the coverage sentence, and updated the adapter inventory wording to include the comments-only discussion fetch. prek run --all-files is passing. |
potiuk
left a comment
There was a problem hiding this comment.
Approving — a clean, security-conscious, read-only addition that follows the existing bitbucket adapter conventions and is well-tested. Particular credit for cloud.py:_validated_next_url: rejecting scheme/host-changing and repeated pagination next URLs before reattaching credentials is real defense-in-depth against redirect-based credential leakage and pagination loops.
A few non-blocking follow-ups you might fold in now or in a fast follow — none block the merge, left inline:
- Data Center threaded replies (nested
comment.comments[]) are silently dropped — a Cloud-parity gap. _cloud_commentis typed… | Nonebut never returnsNone.- The DC discussion path fetches the full
/activitiesfeed and filters to comments afterward. - Test symmetry: the CLI dispatch test only covers Cloud; a DC CLI test would close the gap.
Nice work — thanks @KatalKavya96.
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.
|
@potiuk Thanks for the review and approval. I folded in the non-blocking follow-ups while keeping the PR read-only and within the existing
|
8ef2569 to
053c3ef
Compare
|
Hi @potiuk Could you please confirm whether the PR is good to merge?, so I can proceed with the next implementation. Thanks! |
potiuk
left a comment
There was a problem hiding this comment.
Re-approving on the updated code. The 053c3ef5 fix resolves my earlier finding: Data Center threaded replies are now normalized via _datacenter_comment_tree (recurses comment.comments[], flattens the tree with a parent_id link), with tests — so DC reply coverage now matches Cloud. The _cloud_comment Optional-return and single-element list-comprehension nits are also cleaned up. Nice work @KatalKavya96.
One non-blocking nit for a follow-up: in _datacenter_comment_tree, raw.get("comments", []) still crashes if the API returns an explicit "comments": null (the [] default only applies to a missing key) — raw.get("comments") or [] is safer.
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.
More on how Magpie handles maintainer review: CONTRIBUTING.md.
|
Merged — thanks @KatalKavya96, and thanks for turning the review around so quickly (the Data Center threaded-reply handling via Two optional, non-blocking follow-ups for whenever you're next in this code — neither blocked the merge:
|
Summary
magpie-bitbucket pr discussion <id>as a comments-only, read-onlyget_discussionsubset so Magpie can fetch PR discussion without adding write paths.comments[],participants[],unresolved_count,kind: comment, common inline fields, and updates README/spec wording for external PR content and privacy handling.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-filespassesuv run pytest/ruff check/mypypasses(
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)
PYTHONPATH=src uv run --group dev pytest tests/test_bitbucket.pyRFC-AI-0004 compliance
contract:change-request+Coverage: partial-read-onlymodel without introducing a Bitbucket-specific capability.Linked issues
Refs #606
Notes for reviewers (optional)
This is the next read-only step after the initial Bitbucket bridge and the
partial-read-onlycoverage clarification.The new command is
magpie-bitbucket pr discussion <id>, intended to represent a comments-only subset of theget_discussionsurface while keeping the bridge insideCoverage: partial-read-only. Bitbucket Cloud uses PR comments. Bitbucket Data Center uses PR activities, but filters to comment-bearing /COMMENTEDactivities only.Normalized discussion output now includes
comments[],participants[], andunresolved_count. Each comment includesid,author,date,created,updated,body,kind: comment,deleted,inline, andraw. Inline locations are normalized to a common subset such aspath,from_line, andto_line.Out of scope for this PR: posting comments, reviews, approve/decline/merge operations, Jira handoff, tracker operations, branch permissions, Pipelines status, full activity/event mapping, and unresolved-thread accounting.