OpenBMB/ChatDev · error · WorkflowExecutionError

Failed to rename workflow file

Error message

Failed to rename workflow file

What it means

rename_workflow wraps Path.rename in try/except and re-raises WorkflowExecutionError with source/target details when the OS rename fails (permissions, cross-device link, file vanished between the exists check and the rename). The original exception is logged.

Source

Thrown at server/services/workflow_storage.py:140

        raise ResourceNotFoundError(
            "Workflow file not found",
            resource_type="workflow",
            resource_id=source_safe,
        )

    if target_path.exists():
        raise ResourceConflictError(
            "Target workflow already exists",
            resource_type="workflow",
            resource_id=target_safe,
        )

    logger = get_server_logger()
    try:
        source_path.rename(target_path)
    except Exception as exc:
        logger.log_exception(exc, f"Failed to rename workflow file {source_safe} to {target_safe}")
        raise WorkflowExecutionError(
            "Failed to rename workflow file",
            details={"source": source_safe, "target": target_safe},
        )

    try:
        new_workflow_id = Path(target_safe).stem
        content = target_path.read_text(encoding="utf-8")
        updated = _update_workflow_id(content, new_workflow_id)
        if updated != content:
            target_path.write_text(updated, encoding="utf-8")
    except Exception as exc:
        logger.log_exception(exc, f"Failed to update workflow id after rename to {target_safe}")
        raise WorkflowExecutionError(
            "Failed to update workflow id after rename",
            details={"target": target_safe},
        )

    logger.info(

View on GitHub (pinned to 4fb2db0ea9)

Solutions

  1. Check server logs for the underlying OSError (errno tells you which case)
  2. Retry after confirming both source exists and target is free (race may have cleared)
  3. Fix directory permissions / mount configuration

Example fix

# before
rename_workflow_file(sid, src, tgt)
# after
try:
    rename_workflow_file(sid, src, tgt)
except WorkflowExecutionError:
    refresh_and_retry_once()  # re-check existence/conflict then retry
Defensive patterns

Strategy: retry

Validate before calling

import os
assert (directory/src).exists() and not (directory/tgt).exists()

Try / catch

try:
    rename_workflow_file(sid, src, tgt)
except WorkflowExecutionError:
    if exists(src) and not exists(tgt):
        rename_workflow_file(sid, src, tgt)  # one retry after race clears
    else:
        raise

Prevention

When it happens

Trigger: Directory not writable; source removed by a concurrent process after the existence check (TOCTOU); target created by a concurrent request between check and rename; EXDEV if paths resolve across mount points via symlinks.

Common situations: Concurrent API calls racing; read-only container volume; workflows directory replaced by a symlink to another filesystem.

Related errors


AI-assisted analysis of OpenBMB/ChatDev@4fb2db0ea9 (2026-08-27). Data as JSON: /api/errors/470a55d873e0413d. Report an issue: GitHub.