Skip to content

Conversation

@stsewd
Copy link
Member

@stsewd stsewd commented Oct 30, 2025

Currently, if lsremote fails, we are returning an empty list of branches and tags, which is interpreted by our system as if the branches/tags were deleted, which is incorrect.

I was thinking on raising this exception to the user, but I decided against it, as the user won't be able to fix the problem (it could be a temporal issue), if the repo isn't correctly configured, they will get the error when trying to clone the repo.

@stsewd stsewd requested a review from a team as a code owner October 30, 2025 01:10
@stsewd stsewd requested a review from agjohnson October 30, 2025 01:10
@stsewd stsewd requested a review from Copilot October 30, 2025 01:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds error handling for the git ls-remote command to prevent sync failures when the command fails. The main purpose is to gracefully handle repository access errors during version synchronization.

Key changes:

  • Added exit code checking in lsremote() to raise RepositoryError when the git command fails
  • Added a new error code FAILED_TO_GET_VERSIONS to the RepositoryError exception class
  • Wrapped lsremote() call in a try-except block to catch errors and prevent downstream task execution

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
readthedocs/vcs_support/backends/git.py Added exit code validation to raise RepositoryError when git ls-remote fails
readthedocs/projects/exceptions.py Added new error message ID FAILED_TO_GET_VERSIONS for repository version retrieval failures
readthedocs/projects/tasks/mixins.py Added exception handling to catch RepositoryError from lsremote() and log warning instead of propagating error
readthedocs/rtd_tests/tests/test_backend.py Added test case to verify RepositoryError is raised when git ls-remote returns non-zero exit code
readthedocs/projects/tests/test_build_tasks.py Added test case to verify sync_versions_task is not called when lsremote() raises RepositoryError

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Manuel Kaufmann <humitos@gmail.com>
@stsewd stsewd merged commit 582aa15 into main Oct 30, 2025
7 checks passed
@stsewd stsewd deleted the skip-syncing-on-error branch October 30, 2025 17:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants