Skip to content

Sync reports "success" even when git pull fails (uncommitted local changes / merge conflict) #36

@Azonos712

Description

@Azonos712

Problem

When a repository sync runs git pull and fails (e.g. uncommitted local changes from
the in-app file editor would be overwritten by an incoming merge), the sync task
silently reports success: sync_status is set to "success", sync_error is cleared,
and the UI shows a green checkmark - even though the pull was aborted and the local
working tree was not updated.

This makes editor edits + remote pushes diverge invisibly.

Reproduction

  1. Connect a git repo, let it clone.
  2. Edit any file in the in-app editor and save (writes to working tree, not committed).
  3. From a separate clone, push a change to the same line of the same file.
  4. Click Sync in the repo card.

Expected: UI reports an error along the lines of "local changes would be overwritten,
please discard or stash before sync."

Actual: UI reports success. Logs contain:
Synced : error: Cmd('git') failed due to: exit code(1)
cmdline: git pull -v -- origin
stderr: 'error: Your local changes to the following files would be overwritten by merge:'

The error string is returned by sync_repository but the caller in tasks.py ignores it.

Suggested fix

  1. Surface the git error. In backend/src/repos/service.py:sync_repository — drop the
    try/except that swallows GitCommandError into a return string. Let it propagate;
    the existing except Exception in tasks.py:sync_repo already writes
    sync_status="error" and stores the message.

  2. Add a force-resync endpoint. New force_resync_repository(local_path, branch)
    doing git fetch && git reset --hard origin/<branch> && git clean -fd, exposed via
    POST /repos/{id}/sync?force=true (parallel task in tasks.py).

  3. Recovery action in UI. When sync_status === "error", repo card shows a banner
    "Sync failed: . [Discard local changes & re-pull]". Button calls the new
    ?force=true endpoint. One-click recovery without kubectl exec.

Environment

RoboScope v0.8.2
Self-hosted Kubernetes deployment (single replica, PVC)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions