From 54da8e1d09a732b201d82e286c48bf212ae3843d Mon Sep 17 00:00:00 2001 From: Saeed Date: Sun, 27 Jul 2025 00:27:54 +0330 Subject: [PATCH] fix: improve empty repository URL error --- src/gitingest/query_parser.py | 4 ++++ src/server/models.py | 5 +---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/gitingest/query_parser.py b/src/gitingest/query_parser.py index 6262f0db..fd5eb7e4 100644 --- a/src/gitingest/query_parser.py +++ b/src/gitingest/query_parser.py @@ -40,6 +40,10 @@ async def parse_remote_repo(source: str, token: str | None = None) -> IngestionQ A dictionary containing the parsed details of the repository. """ + if not source.strip(): + msg = "Invalid repository URL: cannot be empty or spaces only." + raise ValueError(msg) + parsed_url = await _normalise_source(source, token=token) host = parsed_url.netloc user, repo = _get_user_and_repo_from_path(parsed_url.path) diff --git a/src/server/models.py b/src/server/models.py index a1aed314..7ba60995 100644 --- a/src/server/models.py +++ b/src/server/models.py @@ -47,10 +47,7 @@ class IngestRequest(BaseModel): @field_validator("input_text") @classmethod def validate_input_text(cls, v: str) -> str: - """Validate that ``input_text`` is not empty.""" - if not v.strip(): - err = "input_text cannot be empty" - raise ValueError(err) + """Validate ``input_text`` field.""" return removesuffix(v.strip(), ".git") @field_validator("pattern")