Validate Repository Name Format in get_branch_list() and check_public_repo()
#354 aperta il 14 apr 2025
Metriche repository
- Star
- (5521 stelle)
- Metriche merge PR
- (Metriche PR in attesa)
Descrizione
Currently, the repo_name parameter in both get_branch_list() and check_public_repo() methods accepts input without any validation. To ensure better integration with the GitHub API and avoid potential errors, we need to implement validation that confirms the repository name adheres to GitHub's naming conventions (e.g., owner/repo).
Proposed Changes:
-
Implement Validation:
- Add a validation check in both methods to ensure
repo_namefollows the required format. - The format should consist of:
- An
ownersegment (alphanumeric characters, dashes, underscores). - A
/separator. - A
reposegment (alphanumeric characters, dashes, underscores).
- An
- Add a validation check in both methods to ensure
-
Error Handling:
- If the provided
repo_namedoes not match the expected format, raise aValueErrorwith a descriptive message explaining the expected format.
- If the provided
-
Testing:
- Write unit tests to cover valid and invalid repository names, ensuring that appropriate exceptions are raised when the format is incorrect.
-
Documentation:
- Update any relevant documentation or docstrings to reflect the new validation logic and provide examples of valid and invalid formats.
Impacted Files:
app/modules/code_provider/github/github_service.py: This file contains theget_branch_list()andcheck_public_repo()methods that will need the validation logic integrated.
Next Steps: If approved, I will begin implementing the validation logic and updating the relevant tests and documentation. Following the implementation, a pull request will be submitted for review.