fix(github-source): refresh state after unchanged syncs
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
- Add a GitHub source to a knowledge base and complete an initial sync.
- Leave the remote branch unchanged so that its current SHA still matches
last_synced_sha. - Make the persisted
last_synced_atolder than 24 hours. Optionally leavelast_sync_status="error"and an oldlast_sync_errorfrom a transient failure. - Run a GitHub source synchronization cycle.
- Observe that the result is successful with
skipped=True. - Inspect the source metadata:
last_synced_at,last_sync_status, andlast_sync_errorare unchanged. - 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_statustosuccess; - clear
last_sync_error; - retain the current
last_synced_sha; - return
skipped=Truewithout 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
mainat commit897fce5 - 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 returndeeptutor/services/github_source/sync_service.py: hourly checks and stale filteringdeeptutor/services/base_sync.py:last_synced_at-based stalenessdeeptutor/services/web_source/sync.py: persists success state after unchanged crawls
Source: HKUDS/DeepTutor