From 169d1bae20458cb1cd0f538c8ec0ae15a4f5c8d2 Mon Sep 17 00:00:00 2001 From: graphlemon Date: Thu, 13 Aug 2026 19:45:43 +0800 Subject: [PATCH] graphlemon: auto-commit uncommitted changes for 46748e02-6e65-49f5-a3ae-2f2bdea93d96-main-checkout-drift --- src/test_work_graph_orchestrate.py | 21 +++++++++++++++++++++ src/work_graph_orchestrate.py | 11 ++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/test_work_graph_orchestrate.py b/src/test_work_graph_orchestrate.py index be9b9f6..f2e634f 100644 --- a/src/test_work_graph_orchestrate.py +++ b/src/test_work_graph_orchestrate.py @@ -547,6 +547,27 @@ class RunFnLogsExecutionEventsTest(RunGraphTestBase): self.assertEqual([e["event"] for e in events], ["node_start", "node_completed"]) self.assertEqual(events[1]["output"], {"content": "brd text"}) + def test_non_ascii_content_written_as_real_utf8_not_escaped(self): + # User-reported (2026-08-13): v_log_viewer reads this .jsonl file's + # raw bytes back and displays each line AS-IS (never JSON.parse()s + # it), unlike every other json.dumps() call in this codebase whose + # output always gets re-parsed before display. Without + # ensure_ascii=False, real Chinese content here showed up in the + # console as literal \uXXXX escape sequences instead of the actual + # characters. + manifest = {"nodes": [{"node_id": "brd", "depends_on": []}], "edges": []} + with patch.object( + org_node_trigger, "trigger_org_node_structured", return_value={"content": "期望行为:真实中文内容"} + ): + wgo.run_graph( + self.conn, "run-1", "planner", "planner-doc-writing", "/tmp/proj-1", manifest, + lambda node, outputs: "p", _IN_SCHEMA, _OUT_SCHEMA, + ) + + raw_content = execution_log.get_log(self.conn, self._node_exec_id())["content"] + self.assertIn("期望行为:真实中文内容", raw_content) + self.assertNotIn("\\u671f", raw_content) # 期 == 期, the escaped form this bug produced + # also exercise the real HTTP-facing read path end to end (not just # the module function) -- an empty file was exactly bug A1. row = self.conn.execute( diff --git a/src/work_graph_orchestrate.py b/src/work_graph_orchestrate.py index 1ca7e5b..95c61b4 100644 --- a/src/work_graph_orchestrate.py +++ b/src/work_graph_orchestrate.py @@ -99,8 +99,17 @@ from src import ( def _log_event(conn, node_exec_id, event_type, **payload): + # ensure_ascii=False (2026-08-13, user-reported): this is the ONLY + # json.dumps() call in the codebase whose output is displayed as raw + # TEXT (v_log_viewer reads the .jsonl file's bytes back and shows each + # line as-is, never JSON.parse()s it back into structured data) -- + # every other json.dumps() call here stores data that's always + # JSON.parse()d/json.loads()d again before display, so the default + # \uXXXX escaping round-trips invisibly there. Here it doesn't: real + # Chinese (or any non-ASCII) content in `payload` showed up as literal + # \uXXXX escape sequences in the console instead of the actual text. execution_log.append_log( - conn, node_exec_id, json.dumps({"event": event_type, **payload}) + "\n" + conn, node_exec_id, json.dumps({"event": event_type, **payload}, ensure_ascii=False) + "\n" ) -- libgit2 0.21.4