potpie-ai/potpie

Validate Repository Name Format in get_branch_list() and check_public_repo()

Open

#354 opened on Apr 14, 2025

 (1 comment) (0 reactions) (0 assignees)Python (642 forks)auto 404
good first issuemaintenance

Repository metrics

Stars
 (5,521 stars)
PR merge metrics
 (PR metrics pending)

Description

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:

  1. Implement Validation:

    • Add a validation check in both methods to ensure repo_name follows the required format.
    • The format should consist of:
      • An owner segment (alphanumeric characters, dashes, underscores).
      • A / separator.
      • A repo segment (alphanumeric characters, dashes, underscores).
  2. Error Handling:

    • If the provided repo_name does not match the expected format, raise a ValueError with a descriptive message explaining the expected format.
  3. Testing:

    • Write unit tests to cover valid and invalid repository names, ensuring that appropriate exceptions are raised when the format is incorrect.
  4. 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 the get_branch_list() and check_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.

Contributor guide