From 461cc2f1cb3c6bef08ae6ae03c5d549b3df79b53 Mon Sep 17 00:00:00 2001 From: ogabrielluiz Date: Thu, 4 Jun 2026 03:18:08 -0300 Subject: [PATCH] test(workflows): guard dead in-memory background machinery stays deleted --- src/backend/base/langflow/api/v2/workflow.py | 8 +++--- .../tests/unit/api/v2/test_workflow_facade.py | 25 +++++++++++++++++++ 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/backend/base/langflow/api/v2/workflow.py b/src/backend/base/langflow/api/v2/workflow.py index 4d09aaa5f0..8a2865b939 100644 --- a/src/backend/base/langflow/api/v2/workflow.py +++ b/src/backend/base/langflow/api/v2/workflow.py @@ -246,10 +246,10 @@ async def execute_workflow( ) if parsed.mode == "background": - # Background owns its own adapter construction inside - # ``_buffer_background_run`` because the fire-and-forget coroutine - # needs its own ``StreamAdapterContext`` (different ``run_id``). - # The name-only check above already covered the 422 contract. + # Background runs are delegated to BackgroundExecutionService via + # ``execute_workflow_background``. The facade creates the durable job + # row, persists the request, enqueues the work, and owns ownership / + # IDOR. The name-only check above already covered the 422 contract. return await execute_workflow_background( parsed=parsed, flow=flow, diff --git a/src/backend/tests/unit/api/v2/test_workflow_facade.py b/src/backend/tests/unit/api/v2/test_workflow_facade.py index c45ecd1389..eb1c94c7d2 100644 --- a/src/backend/tests/unit/api/v2/test_workflow_facade.py +++ b/src/backend/tests/unit/api/v2/test_workflow_facade.py @@ -323,3 +323,28 @@ class TestNoBreakingChange: assert response.status_code == 200 event_ids = [line.removeprefix("id:").strip() for line in response.text.splitlines() if line.startswith("id:")] assert "0" not in event_ids + + +class TestDeadMachineryRemoved: + """The process-local background buffer machinery is gone after the cutover. + + ``execute_workflow_background`` is intentionally kept: it is now a thin + facade-delegating wrapper (builds the request dict, threads idempotency_key), + not the old in-memory run loop, so it is NOT in this list. + """ + + def test_in_memory_background_machinery_is_deleted(self): + """The old _BackgroundRun buffer and its helpers no longer exist.""" + from langflow.api.v2 import workflow as wf + + for name in ( + "_BackgroundRun", + "_BACKGROUND_RUNS", + "_register_background_run", + "_clear_background_run", + "_buffer_background_run", + "_finalize_job_status", + "_MAX_BACKGROUND_RUNS", + "_MAX_FRAMES_PER_BACKGROUND_RUN", + ): + assert not hasattr(wf, name), f"{name} should have been deleted in the facade cutover"