From dcda5de69da1d537f583803e525343f783697bcb Mon Sep 17 00:00:00 2001 From: Dan Wolfson Date: Tue, 17 Nov 2026 08:36:45 -0600 Subject: [PATCH 01/16] fix(feedback): add_like_to_element sends the caller's emoji, with no hard-coded zone With an emoji and no body, the request carried the docstring placeholder "Add characters here as text" instead of the emoji, and put the like in a ZoneMembership hard-coded to erinoverview. The body now holds the emoji passed in and no zone. A caller that wants a zone passes its own body. Calls without an emoji, or with the caller's own body, are unchanged. The Portal's likes send no emoji, so they were never affected. Reported by Peter (via Dan, 2026-11-17). Signed-off-by: Dan Wolfson --- pyegeria/core/_server_client.py | 10 +--- tests/micro-tests/test_add_like_emoji_body.py | 59 +++++++++++++++++++ 2 files changed, 62 insertions(+), 7 deletions(-) create mode 100644 tests/micro-tests/test_add_like_emoji_body.py diff --git a/pyegeria/core/_server_client.py b/pyegeria/core/_server_client.py index 99a47c4f..d60ad964 100644 --- a/pyegeria/core/_server_client.py +++ b/pyegeria/core/_server_client.py @@ -5015,17 +5015,13 @@ async def _async_add_like_to_element( """ if body is None and emoji: + # The like carries the caller's emoji. No zone is set here: a caller that wants the like in a + # zone passes its own body with initialClassifications.ZoneMembership. body = { "class" : "NewAttachmentRequestBody", - "initialClassifications" : { - "ZoneMembership" : { - "class" : "ZoneMembershipProperties", - "zoneMembership" : "erinoverview" - } - }, "properties" : { "class" : "LikeProperties", - "emoji" : "Add characters here as text" + "emoji" : emoji } } url = f"{self.command_root}feedback-manager/elements/{element_guid}/likes" diff --git a/tests/micro-tests/test_add_like_emoji_body.py b/tests/micro-tests/test_add_like_emoji_body.py new file mode 100644 index 00000000..dd6951fb --- /dev/null +++ b/tests/micro-tests/test_add_like_emoji_body.py @@ -0,0 +1,59 @@ +""" +add_like_to_element ignored the emoji it was given. With an emoji it sent the docstring placeholder +"Add characters here as text" and put the like in a zone hard-coded to erinoverview. Now the body carries the +caller's emoji and no zone; without an emoji (or with the caller's own body) the request is as before. +""" +import json + +from pyegeria.core._server_client import ServerClient + + +class _Response: + def json(self): + return {"relatedHTTPCode": 200, "guid": "like-guid"} + + +def _capture(monkeypatch): + monkeypatch.setattr(ServerClient, "check_connection", lambda self: "test", raising=False) + client = ServerClient("view-server", "https://localhost:1", "user", "pwd") + calls: list = [] + + async def fake_make_request(method, url, payload=None, *args, **kwargs): + calls.append((method, url, json.loads(payload) if isinstance(payload, str) else payload)) + return _Response() + + client._async_make_request = fake_make_request + return client, calls + + +def test_the_emoji_passed_is_the_emoji_sent(monkeypatch): + client, calls = _capture(monkeypatch) + client.add_like_to_element("elem-guid", emoji="👍") + method, url, body = calls[-1] + assert method == "POST" and url.endswith("feedback-manager/elements/elem-guid/likes") + assert body["properties"] == {"class": "LikeProperties", "emoji": "👍"} + + +def test_no_zone_is_hard_coded(monkeypatch): + client, calls = _capture(monkeypatch) + client.add_like_to_element("elem-guid", emoji="❤️") + body = calls[-1][2] + assert "initialClassifications" not in body + assert "erinoverview" not in json.dumps(body) + assert "Add characters here" not in json.dumps(body, ensure_ascii=False) + + +def test_without_an_emoji_no_body_is_sent(monkeypatch): + client, calls = _capture(monkeypatch) + client.add_like_to_element("elem-guid") + assert calls[-1][2] is None + + +def test_a_callers_own_body_is_sent_unchanged(monkeypatch): + client, calls = _capture(monkeypatch) + own = {"class": "NewAttachmentRequestBody", + "initialClassifications": {"ZoneMembership": {"class": "ZoneMembershipProperties", + "zoneMembership": ["mine"]}}, + "properties": {"class": "LikeProperties", "emoji": "🎉"}} + client.add_like_to_element("elem-guid", emoji="👍", body=own) + assert calls[-1][2] == own From 8c10b40a5d4a1fd1ae5f8b273f25c45a418d48ed Mon Sep 17 00:00:00 2001 From: Dan Wolfson Date: Tue, 17 Nov 2026 08:52:41 -0600 Subject: [PATCH 02/16] fix(feedback): PY-29 read-back R1/R2 - correct the like comment and body class R1: the comment said a caller could zone a like by passing its own body. This endpoint ignores initialClassifications, and Egeria anchors a Like to the liked element, so it is exactly as visible as that element. R2: the endpoint reads UpdateElementRequestBody, so use that class. It behaves the same, since the class is ignored. Signed-off-by: Dan Wolfson --- pyegeria/core/_server_client.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pyegeria/core/_server_client.py b/pyegeria/core/_server_client.py index d60ad964..7852ade6 100644 --- a/pyegeria/core/_server_client.py +++ b/pyegeria/core/_server_client.py @@ -5015,10 +5015,10 @@ async def _async_add_like_to_element( """ if body is None and emoji: - # The like carries the caller's emoji. No zone is set here: a caller that wants the like in a - # zone passes its own body with initialClassifications.ZoneMembership. + # The like carries the caller's emoji. No zone is set: Egeria anchors a Like to the liked element, + # so it is exactly as visible as that element (this endpoint ignores initialClassifications). body = { - "class" : "NewAttachmentRequestBody", + "class" : "UpdateElementRequestBody", "properties" : { "class" : "LikeProperties", "emoji" : emoji From c70b757c5dfe4647ae724bb2d3c3192a283b784c Mon Sep 17 00:00:00 2001 From: Dan Wolfson Date: Tue, 17 Nov 2026 14:52:44 -0600 Subject: [PATCH 03/16] docs(collections): delete_collection's cascade defaults to False, as the code does (PY-31) Both the async and sync docstrings said "defaults to True", but both signatures default cascade to False. A reader trusting the docstring could misjudge what a default delete removes. Docstrings only; no behaviour change. Signed-off-by: Dan Wolfson --- pyegeria/omvs/collection_manager.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyegeria/omvs/collection_manager.py b/pyegeria/omvs/collection_manager.py index 2e9c08b4..7a2cc5cd 100644 --- a/pyegeria/omvs/collection_manager.py +++ b/pyegeria/omvs/collection_manager.py @@ -6707,7 +6707,7 @@ async def _async_delete_collection(self, collection_guid: str, body: dict | Dele collection_guid: str The guid of the collection to delete. - cascade: bool, optional, defaults to True + cascade: bool, optional, defaults to False If true, a cascade delete is performed. body: dict | DeleteElementRequestBody, optional, default = None @@ -6757,7 +6757,7 @@ def delete_collection(self, collection_guid: str, body: Optional[dict | DeleteEl collection_guid: str The guid of the collection to delete. - cascade: bool, optional, defaults to True + cascade: bool, optional, defaults to False If true, a cascade delete is performed. body: dict | DeleteElementRequestBody, optional, default = None From 022d6dca17131d4747556e5c1f4feaf780b96a6c Mon Sep 17 00:00:00 2001 From: Dan Wolfson Date: Tue, 17 Nov 2026 14:57:49 -0600 Subject: [PATCH 04/16] feat(dr-egeria): UniversalExtractor.diagnose() says why a block runs less than meant (PY-30) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A Dr.Egeria command is an H2 heading "## " with H3 attributes. Two heading mistakes passed silently: - "# Delete Instance" (H1) is kept as prose, so the document runs no command and reports success with 0 commands; - an attribute written as H2 ("## Delete Method") matches the command pattern and becomes a bogus command of its own. diagnose() returns hints in words: - an H1 line that is a command heading → write it as '## …'; - an H2 "command" whose name is an attribute of the command just above it, per the compact command specs → write it as '### …'; - no command at all → the expected shape. The spec lookup is optional (an explicit mapping can be passed), and diagnose() never fails extraction. Tests: tests/micro-tests/test_extraction_diagnose.py (7 cases). The micro-test suite has the same 15 failure names on base and branch. Signed-off-by: Dan Wolfson --- md_processing/v2/extraction.py | 79 +++++++++++++++++++ tests/micro-tests/test_extraction_diagnose.py | 49 ++++++++++++ 2 files changed, 128 insertions(+) create mode 100644 tests/micro-tests/test_extraction_diagnose.py diff --git a/md_processing/v2/extraction.py b/md_processing/v2/extraction.py index dd92588b..59afead9 100644 --- a/md_processing/v2/extraction.py +++ b/md_processing/v2/extraction.py @@ -154,6 +154,54 @@ def extract_commands(self) -> List[DrECommand]: )) return commands + def diagnose(self, command_attributes: Optional[Dict[str, List[str]]] = None) -> List[str]: + """Explain, in words, heading mistakes that make a document run less than its author meant (PY-30). + + A Dr.Egeria command is an H2 heading ``## `` with its attributes as H3 ``###