Skip to content

fix(github-source): refresh state after unchanged syncs #1489

Description

@AoHanBei

Do you need to file an issue?

  • I have searched the existing issues and this bug is not already filed.
  • I believe this is a legitimate bug, not just a question or feature request.

Describe the bug

GitHub knowledge sources do not refresh their persisted sync state when the remote branch still points to the previously synced commit.

In deeptutor/services/github_source/sync.py, sync_source() returns immediately when old_sha == latest_sha:

if old_sha and old_sha == latest_sha:
    return SyncResult(ok=True, skipped=True)

This successful remote check does not update last_synced_at, set last_sync_status back to success, or clear a previous last_sync_error.
The background service uses last_synced_at to determine whether a source is stale and checks sources every hour. Once an unchanged source becomes older than the 24-hour freshness window, every subsequent hourly cycle checks GitHub again but leaves the source stale.
A previous transient sync error also remains visible even after a later GitHub check succeeds and confirms that the source is current.
The web-source sync path already persists a fresh success state after an unchanged crawl, so the two source types currently behave differently.

Steps to reproduce

  1. Add a GitHub source to a knowledge base and complete an initial sync.
  2. Leave the remote branch unchanged so that its current SHA still matches last_synced_sha.
  3. Make the persisted last_synced_at older than 24 hours. Optionally leave last_sync_status="error" and an old last_sync_error from a transient failure.
  4. Run a GitHub source synchronization cycle.
  5. Observe that the result is successful with skipped=True.
  6. Inspect the source metadata: last_synced_at, last_sync_status, and last_sync_error are unchanged.
  7. Run the background cycle again. The source is still considered stale and GitHub is queried again.

Expected Behavior

A successful same-SHA check should persist a fresh synchronization state:

  • refresh last_synced_at;
  • set last_sync_status to success;
  • clear last_sync_error;
  • retain the current last_synced_sha;
  • return skipped=True without downloading or re-indexing files.

The source should then remain fresh until the next 24-hour synchronization window.

Related Module

Knowledge Base Management

Configuration Used

A knowledge base with a GitHub source whose last_synced_sha matches the current remote branch SHA and whose last_synced_at is older than the 24-hour synchronization interval.

Logs and screenshots

No runtime log is required to reproduce this issue. The behavior follows directly from the same-SHA early return in deeptutor/services/github_source/sync.py.

Additional Information

  • DeepTutor Version: latest main at commit 897fce5
  • Operating System: platform-independent
  • Python Version: not environment-specific
  • Node.js Version: not applicable
  • Browser: not applicable
  • Related Issues: none found

Relevant code:

  • deeptutor/services/github_source/sync.py: same-SHA early return
  • deeptutor/services/github_source/sync_service.py: hourly checks and stale filtering
  • deeptutor/services/base_sync.py: last_synced_at-based staleness
  • deeptutor/services/web_source/sync.py: persists success state after unchanged crawls

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions