{"record":{"id":"4ed3d0126e26720d","repo":"666ghj/MiroFish","slug":"simulation-id","errorCode":null,"errorMessage":"模拟不存在: {simulation_id}","messagePattern":"模拟不存在: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"backend/app/services/simulation_manager.py","lineNumber":278,"sourceCode":"        3. 使用LLM智能生成模拟配置参数（时间、活跃度、发言频率等）\n        4. 保存配置文件和Profile文件\n        5. 复制预设脚本到模拟目录\n        \n        Args:\n            simulation_id: 模拟ID\n            simulation_requirement: 模拟需求描述（用于LLM生成配置）\n            document_text: 原始文档内容（用于LLM理解背景）\n            defined_entity_types: 预定义的实体类型（可选）\n            use_llm_for_profiles: 是否使用LLM生成详细人设\n            progress_callback: 进度回调函数 (stage, progress, message)\n            parallel_profile_count: 并行生成人设的数量，默认3\n            \n        Returns:\n            SimulationState\n        \"\"\"\n        state = self._load_simulation_state(simulation_id)\n        if not state:\n            raise ValueError(f\"模拟不存在: {simulation_id}\")\n        \n        try:\n            state.status = SimulationStatus.PREPARING\n            state.error = None\n            state.profiles_generated = False\n            state.config_generated = False\n            state.config_reasoning = \"\"\n            self._save_simulation_state(state)\n            \n            sim_dir = self._get_simulation_dir(simulation_id)\n            \n            # ========== 阶段1: 读取并过滤实体 ==========\n            if progress_callback:\n                progress_callback(\"reading\", 0, t('progress.connectingZepGraph'))\n            \n            reader = ZepEntityReader()\n            \n            if progress_callback:","sourceCodeStart":260,"sourceCodeEnd":296,"githubUrl":"https://github.com/666ghj/MiroFish/blob/b5b53acc57189a4a42e44a23e149dc655c98fe82/backend/app/services/simulation_manager.py#L260-L296","documentation":"Raised in SimulationManager.prepare_simulation: it loads persisted simulation state via _load_simulation_state(simulation_id), and if no state file exists it raises ValueError('模拟不存在: ...'). This is a plain not-found guard — the simulation id was never created (or its state file was deleted) before prepare was called.","triggerScenarios":"Calling prepare with an id that was never registered through create_simulation; state files wiped (deleted data dir, fresh container without a volume); typo'd or truncated simulation_id from the client; calling prepare on a simulation from a different backend instance.","commonSituations":"Backend restarted against a new/empty persistence directory; Docker volume for simulation state not mounted; frontend holding a stale id after environment reset; manual cleanup of the simulations directory.","solutions":["Create the simulation first via the create endpoint, then call prepare with the returned id.","Verify the state file exists on disk in the manager's simulation directory for that id (list simulations via the manager's list method).","If state was lost due to container recreation, remount the persistent volume holding simulation state and retry.","Check for id truncation/encoding issues in the client (whitespace, wrong copy)."],"exampleFix":"# before\nmanager.prepare_simulation('sim-123', ...)\n# after\nif not manager._load_simulation_state('sim-123'):\n    state = manager.create_simulation(project_id='p1', ...)  # get real id\nmanager.prepare_simulation(state.simulation_id, ...)","handlingStrategy":"validation","validationCode":"if not manager._load_simulation_state(simulation_id):\n    raise HTTPException(404, f'simulation {simulation_id} not found')","typeGuard":null,"tryCatchPattern":"try:\n    manager.prepare_simulation(sim_id, ...)\nexcept ValueError as e:\n    if '不存在' in str(e):\n        raise HTTPException(404, str(e)) from e\n    raise","preventionTips":["Mount simulation state on a persistent volume so restarts don't lose it.","Return 404 from routes when the not-found ValueError fires, not 500.","Have the frontend refresh its simulation list after environment resets."],"tags":["simulation","not-found","state","validation"],"backgroundTag":null,"analyzedSha":"b5b53acc57189a4a42e44a23e149dc655c98fe82","analyzedAt":"2026-08-14T22:29:33.146Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}