{"record":{"id":"258db727475c08c2","repo":"666ghj/MiroFish","slug":"graph-id","errorCode":null,"errorMessage":"启用图谱记忆更新时必须提供 graph_id","messagePattern":"启用图谱记忆更新时必须提供 graph_id","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"backend/app/services/simulation_runner.py","lineNumber":443,"sourceCode":"        # STARTING state makes every concurrent start fail closed.\n        with cls._finalization_lock(simulation_id):\n            existing = cls.get_run_state(simulation_id)\n            active_statuses = {\n                RunnerStatus.STARTING,\n                RunnerStatus.RUNNING,\n                RunnerStatus.PAUSED,\n                RunnerStatus.STOPPING,\n            }\n            if (\n                existing and existing.runner_status in active_statuses\n            ) or ZepGraphMemoryManager.get_updater(simulation_id) is not None:\n                raise ValueError(f\"模拟已在运行或结束处理中: {simulation_id}\")\n            cls._save_run_state(state)\n        \n        # 如果启用图谱记忆更新，创建更新器\n        if enable_graph_memory_update:\n            if not graph_id:\n                raise ValueError(\"启用图谱记忆更新时必须提供 graph_id\")\n            \n            try:\n                ZepGraphMemoryManager.create_updater(simulation_id, graph_id)\n                cls._graph_memory_enabled[simulation_id] = True\n                logger.info(f\"已启用图谱记忆更新: simulation_id={simulation_id}, graph_id={graph_id}\")\n            except Exception as e:\n                logger.error(f\"创建图谱记忆更新器失败: {e}\")\n                cls._graph_memory_enabled[simulation_id] = False\n                state.runner_status = RunnerStatus.FAILED\n                state.error = f\"Zep图谱更新器初始化失败: {e}\"\n                with cls._finalization_lock(simulation_id):\n                    cls._save_run_state(state)\n                    cls._sync_simulation_status(\n                        simulation_id,\n                        RunnerStatus.FAILED,\n                        state.error,\n                    )\n                raise RuntimeError(state.error) from e","sourceCodeStart":425,"sourceCodeEnd":461,"githubUrl":"https://github.com/666ghj/MiroFish/blob/b5b53acc57189a4a42e44a23e149dc655c98fe82/backend/app/services/simulation_runner.py#L425-L461","documentation":"Raised in SimulationRunner's start path: when enable_graph_memory_update is true, graph_id must be supplied; otherwise ValueError('启用图谱记忆更新时必须提供 graph_id'). The graph memory updater writes agent activity back to a specific Zep graph, and without a target graph id there is nothing valid to write to — the code prefers failing over silently disabling the feature.","triggerScenarios":"Calling start with enable_graph_memory_update=True but omitting graph_id (e.g. the route's optional graph_id field left null by the client); passing an empty string graph_id (falsy); frontend not propagating the project's graph_id when the toggle is enabled.","commonSituations":"New UI toggle for graph memory shipped without wiring the graph_id field; API clients copying an old request body that predates the feature; graph_id passed under a different JSON key than the route expects.","solutions":["Pass the project's Zep graph_id whenever enable_graph_memory_update is true.","Or set enable_graph_memory_update=false if you don't need agent activity written back to the graph.","Validate the pairing at the API boundary so the request fails with a 422 before reaching the runner.","In the frontend, auto-fill graph_id from the project when the toggle is enabled and disable start until present."],"exampleFix":"# before\nrunner.start_simulation(sim_id, enable_graph_memory_update=True)  # graph_id omitted\n# after\nrunner.start_simulation(\n    sim_id,\n    enable_graph_memory_update=True,\n    graph_id=project.graph_id,  # from the project/graph that was built\n)","handlingStrategy":"validation","validationCode":"if enable_graph_memory_update and not graph_id:\n    raise HTTPException(422, 'graph_id is required when enable_graph_memory_update is true')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate the (enable_graph_memory_update, graph_id) pairing in the API schema (FastAPI dependency or pydantic model_validator).","Auto-populate graph_id from the project in the frontend when the toggle is on.","Reject empty-string graph_id the same as missing — both are falsy."],"tags":["simulation","zep","graph-memory","validation","config"],"backgroundTag":null,"analyzedSha":"b5b53acc57189a4a42e44a23e149dc655c98fe82","analyzedAt":"2026-08-14T22:29:33.146Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}