Skip to content

Commit a37d85f

Browse files
committed
fix(validation): allow repo names starting with period
GitHub allows repository names that start with a period (e.g., .github, .dotfiles). Updated REPO_COMPONENT_PATTERN to accept names starting with alphanumeric OR period. This fixes the "Invalid repository name format" error when selecting repositories from the GitHub API.
1 parent 61115b2 commit a37d85f

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/github_analyzer/config/validation.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@
3737

3838
# Repository name validation
3939
# GitHub allows: alphanumeric, hyphen, underscore, period
40+
# Names can start with alphanumeric or period (e.g., .github, .dotfiles)
4041
# Max 100 characters per component
41-
REPO_COMPONENT_PATTERN = r"^[a-zA-Z0-9][a-zA-Z0-9._-]{0,99}$"
42-
REPO_FULL_PATTERN = r"^[a-zA-Z0-9][a-zA-Z0-9._-]{0,99}/[a-zA-Z0-9][a-zA-Z0-9._-]{0,99}$"
42+
REPO_COMPONENT_PATTERN = r"^[a-zA-Z0-9.][a-zA-Z0-9._-]{0,99}$"
43+
REPO_FULL_PATTERN = r"^[a-zA-Z0-9.][a-zA-Z0-9._-]{0,99}/[a-zA-Z0-9.][a-zA-Z0-9._-]{0,99}$"
4344

4445
# Dangerous characters that could indicate injection attempts
4546
DANGEROUS_CHARS = set(";|&$`(){}[]<>\\'\"\n\r\t")
@@ -207,7 +208,7 @@ def from_string(cls, repo_str: str) -> Repository:
207208
if not re.match(REPO_COMPONENT_PATTERN, owner):
208209
raise ValidationError(
209210
"Invalid repository owner format",
210-
details="Owner must start with alphanumeric and contain only alphanumeric, hyphen, underscore, or period",
211+
details="Owner must start with alphanumeric or period and contain only alphanumeric, hyphen, underscore, or period",
211212
)
212213

213214
# Validate name
@@ -216,7 +217,7 @@ def from_string(cls, repo_str: str) -> Repository:
216217
if not re.match(REPO_COMPONENT_PATTERN, name):
217218
raise ValidationError(
218219
"Invalid repository name format",
219-
details="Name must start with alphanumeric and contain only alphanumeric, hyphen, underscore, or period",
220+
details="Name must start with alphanumeric or period and contain only alphanumeric, hyphen, underscore, or period",
220221
)
221222

222223
# Check for path traversal

0 commit comments

Comments
 (0)