666ghj/MiroFish · error · ValueError
脚本不存在: {script_path}
Error message
脚本不存在: {script_path} What it means
Raised by SimulationRunner.start_simulation when the OASIS simulation script path passed in the config does not exist on disk. Before raising, the runner marks the run FAILED, clears twitter/reddit running flags, appends any Zep graph-write cleanup failure to the message, persists run state, and syncs status. The ValueError surfaces the composed state.error string to the caller.
Source
Thrown at backend/app/services/simulation_runner.py:500
try:
ZepGraphMemoryManager.stop_updater(simulation_id)
cls._graph_memory_enabled.pop(simulation_id, None)
except Exception as error:
cleanup_error = error
state.runner_status = RunnerStatus.FAILED
state.twitter_running = False
state.reddit_running = False
state.error = f"脚本不存在: {script_path}"
if cleanup_error is not None:
state.error += f"; Zep图谱写入清理失败: {cleanup_error}"
with cls._finalization_lock(simulation_id):
cls._save_run_state(state)
cls._sync_simulation_status(
simulation_id,
RunnerStatus.FAILED,
state.error,
)
raise ValueError(state.error)
# 创建动作队列
action_queue = Queue()
cls._action_queues[simulation_id] = action_queue
process = None
main_log_file = None
# 启动模拟进程
try:
# 构建运行命令,使用完整路径
# 新的日志结构:
# twitter/actions.jsonl - Twitter 动作日志
# reddit/actions.jsonl - Reddit 动作日志
# simulation.log - 主进程日志
cmd = [
sys.executable, # Python解释器View on GitHub (pinned to b5b53acc57)
Solutions
- Verify the exact path in the error message exists on the machine running the backend (ls the path from the message).
- Make script_path absolute (or resolve it against a project-configured base directory) before calling start_simulation.
- Re-generate the simulation config so script_path matches the current script location shipped with the deployment.
- If the '; Zep图谱写入清理失败' suffix appears, also fix the Zep connection/key issue reported there — the run failed for both reasons.
Example fix
// before
config.script_path = "scripts/run_twitter_simulation.py"; // resolved from unknown CWD
// after
import app_config
config.script_path = str(
(Path(app_config.PROJECT_ROOT) / "scripts" / "run_twitter_simulation.py").resolve()
);
if not Path(config.script_path).exists():
raise FileNotFoundError(config.script_path); Defensive patterns
Strategy: validation
Validate before calling
from pathlib import Path
def can_start(config) -> tuple[bool, str]:
p = Path(config.script_path)
if not p.is_absolute():
return False, "script_path must be absolute"
if not p.is_file():
return False, f"script missing: {p}"
return True, "" Type guard
def is_startable_config(config) -> bool:
p = Path(getattr(config, "script_path", ""))
return p.is_absolute() and p.is_file() Try / catch
try:
SimulationRunner.start_simulation(cfg)
except ValueError as e:
if str(e).startswith("脚本不存在"):
# surface as config error, not server error
raise HTTPException(400, detail=str(e))
raise Prevention
- Store absolute script paths in generated configs.
- Fail CI/deploy checks when the scripts directory is absent from the artifact.
- Validate script_path existence in the config-generation step, not only at start.
When it happens
Trigger: Calling start_simulation (or the API endpoint that wraps it) with a config whose script_path points to a missing/unmounted file; the runner builds the full path from config and the os.path/existence precheck fails. The message may also carry '; Zep图谱写入清理失败: ...' when the cleanup of a previously started graph updater also errored.
Common situations: Relative script paths resolved against the wrong CWD (backend started from repo root vs backend/), renamed or moved simulation scripts, deployment where the scripts directory is not shipped or mounted, or a stale config JSON referencing an old script name.
Related errors
- 等待命令响应超时 ({timeout}秒)
- 模拟不存在: {simulation_id}
- 没有找到符合条件的实体,请检查图谱是否正确构建
- 不支持的平台: {platform}
- 模拟配置不存在,请先调用 /prepare 接口
AI-assisted analysis of 666ghj/MiroFish@b5b53acc57 (2026-08-14).
Data as JSON: /api/errors/964993d5aff7ba90.
Report an issue: GitHub.