You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@magpie.apache.org by po...@apache.org on 2026/07/09 09:35:52 UTC

(magpie) branch main updated: fix(bitbucket): tolerate null datacenter comment replies (#792)

This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/magpie.git


The following commit(s) were added to refs/heads/main by this push:
     new cfc69b59 fix(bitbucket): tolerate null datacenter comment replies (#792)
cfc69b59 is described below

commit cfc69b59c8714530c6175dc142bb3cd3e1ed23e2
Author: Kavya Katal <KA...@GMAIL.COM>
AuthorDate: Thu Jul 9 15:05:47 2026 +0530

    fix(bitbucket): tolerate null datacenter comment replies (#792)
---
 tools/bitbucket/src/magpie_bitbucket/normalize.py |  2 +-
 tools/bitbucket/tests/test_bitbucket.py           | 25 +++++++++++++++++++++++
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/tools/bitbucket/src/magpie_bitbucket/normalize.py b/tools/bitbucket/src/magpie_bitbucket/normalize.py
index 14dfba13..e8e584c2 100644
--- a/tools/bitbucket/src/magpie_bitbucket/normalize.py
+++ b/tools/bitbucket/src/magpie_bitbucket/normalize.py
@@ -191,7 +191,7 @@ def _datacenter_comment_tree(
     normalized = _datacenter_comment(raw, activity, parent_id)
 
     replies: list[dict[str, Any]] = []
-    for reply in raw.get("comments", []):
+    for reply in raw.get("comments") or []:
         if isinstance(reply, dict):
             replies.extend(_datacenter_comment_tree(reply, activity, normalized["id"]))
 
diff --git a/tools/bitbucket/tests/test_bitbucket.py b/tools/bitbucket/tests/test_bitbucket.py
index 2f5eb90a..809b09e9 100644
--- a/tools/bitbucket/tests/test_bitbucket.py
+++ b/tools/bitbucket/tests/test_bitbucket.py
@@ -557,6 +557,31 @@ def test_normalize_datacenter_discussion_includes_threaded_replies() -> None:
     assert result["participants"] == ["Asha", "Ravi"]
 
 
+def test_normalize_datacenter_discussion_allows_null_threaded_replies() -> None:
+    raw = {
+        "pull_request_id": "9",
+        "values": [
+            {
+                "action": "COMMENTED",
+                "comment": {
+                    "id": 1,
+                    "text": "Parent comment",
+                    "author": {"displayName": "Asha"},
+                    "createdDate": 1783428000000,
+                    "comments": None,
+                },
+            }
+        ],
+    }
+
+    result = pull_request_discussion("datacenter", raw)
+
+    assert len(result["comments"]) == 1
+    assert result["comments"][0]["body"] == "Parent comment"
+    assert result["comments"][0]["parent_id"] is None
+    assert result["participants"] == ["Asha"]
+
+
 def test_normalize_datacenter_discussion_filters_non_comment_activities() -> None:
     raw = {
         "pull_request_id": "9",