Skip to content

Fix race condition in global _current_task tracking #5

@chenhaot

Description

@chenhaot

bot.py uses a single global _current_task variable to track work-in-progress, but cmd_review at line 323 creates a task via asyncio.create_task(do_review()) without assigning it to _current_task or checking if work is already running. This means:

  1. A review can run concurrently with a /work or /pr task on the same repo, causing git conflicts in the shared workspace directory (both operations clone/checkout in the same workspace_dir/<repo> path).
  2. The review task is fire-and-forget with no reference kept, so if the bot shuts down mid-review, the task is silently cancelled with no cleanup.

Fix: Guard cmd_review with the same _current_task check used by cmd_work and cmd_pr, and assign the task to _current_task. Alternatively, use a dict of per-repo locks to allow concurrent work on different repos while preventing conflicts on the same repo.


Identified by minbot code review

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions