diff --git a/cloud/tests/test_worker_playwright_seed_f821.py b/cloud/tests/test_worker_playwright_seed_f821.py index 8e2f0bd..39cffa6 100644 --- a/cloud/tests/test_worker_playwright_seed_f821.py +++ b/cloud/tests/test_worker_playwright_seed_f821.py @@ -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", diff --git a/cloud/worker.py b/cloud/worker.py index 302469c..38acca4 100644 --- a/cloud/worker.py +++ b/cloud/worker.py @@ -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: # 技能播种失败绝不阻塞任务:技能是可选的流程