code-to10 reconcile: fix pre-existing worker F821 in playwright skipped-modified log branch
Target-line bug, not introduced by the replay: Worker._tenant_dirs
only receives project_id, yet the script_skipped_modified log line
used task.get("project_id"), raising NameError whenever seeding
reported a tenant-modified script (the refreshed sibling branch was
already fixed to project_id with its own regression test; this test
only covered the refreshed branch, so the full suite stayed green).
Fix mirrors the sibling (project_id) plus a regression test for the
skipped branch. Ruff F821 in worker.py is thereby cleared.
This commit is contained in:
1 parent
34b9a34896
commit
055da3c2dd
2 files changed
+21
-1
No files matched your search
@@ -71,6 +71,22 @@ class WorkerPlaywrightSeedF821TestCase(unittest.TestCase):
|
||||
self.assertTrue(any("projA" in line and "playwright_mcp.py" in line
|
||||
for line in logs.output))
|
||||
|
||||
def test_skipped_modified_script_logs_project_id_without_name_error(self):
|
||||
# Sibling of the refreshed branch: the skipped-modified log
|
||||
# line still used task.get("project_id") with no task in scope
|
||||
# (ruff F821), raising NameError whenever seeding reported a
|
||||
# tenant-modified script. Fixed to project_id, same pattern
|
||||
# as the refreshed branch above.
|
||||
worker = self._worker()
|
||||
with mock.patch("cloud.worker._ensure_playwright_mcp",
|
||||
return_value={"script_skipped_modified":
|
||||
["playwright_mcp.py"]}):
|
||||
with self.assertLogs(worker.logger, level="WARNING") as logs:
|
||||
dirs = worker._tenant_dirs("projA")
|
||||
self.assertIn("codex_home", dirs)
|
||||
self.assertTrue(any("projA" in line and "playwright_mcp.py" in line
|
||||
for line in logs.output))
|
||||
|
||||
def test_no_refresh_still_seeds(self):
|
||||
worker = self._worker()
|
||||
with mock.patch("cloud.worker._ensure_playwright_mcp",
|
||||
|
||||
+5
-1
@@ -3026,10 +3026,14 @@ class Worker:
|
||||
project_id,
|
||||
",".join(_seeded["script_refreshed"]))
|
||||
if _seeded.get("script_skipped_modified"):
|
||||
# Sibling of the refreshed branch above: _tenant_dirs
|
||||
# only receives project_id, there is no task in scope;
|
||||
# the pre-existing task.get() here raised NameError
|
||||
# whenever seeding reported a tenant-modified script.
|
||||
self.logger.warning(
|
||||
"playwright MCP scripts skipped (tenant-modified, "
|
||||
"left untouched, see audit) for project %s: %s",
|
||||
task.get("project_id"),
|
||||
project_id,
|
||||
",".join(_seeded["script_skipped_modified"]))
|
||||
if self.seed_skills:
|
||||
# 技能播种失败绝不阻塞任务:技能是可选的流程
|
||||
|
||||
Reference in new issue
Block a user