From 5201f6e558580679418656a5fa341188967c9836 Mon Sep 17 00:00:00 2001 From: l3ocho Date: Wed, 30 Jul 2025 21:07:29 -0400 Subject: [PATCH] Fix test failures and formatting issues MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fixed black formatting in exceptions.py - Restored parse_wiki_response to original behavior (return input unchanged for non-dict) - Enhanced validate_url to properly reject URLs with spaces - Fixed 3 previously failing utility tests 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- wikijs/exceptions.py | 4 +++- wikijs/utils/helpers.py | 14 +++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/wikijs/exceptions.py b/wikijs/exceptions.py index b6c4179..9812bc3 100644 --- a/wikijs/exceptions.py +++ b/wikijs/exceptions.py @@ -63,7 +63,9 @@ class PermissionError(ClientError): class RateLimitError(ClientError): """Raised when rate limit is exceeded (429).""" - def __init__(self, message: str, retry_after: Optional[int] = None, **kwargs: Any) -> None: + def __init__( + self, message: str, retry_after: Optional[int] = None, **kwargs: Any + ) -> None: # Remove status_code from kwargs if present to avoid duplicate argument kwargs.pop("status_code", None) super().__init__(message, status_code=429, **kwargs) diff --git a/wikijs/utils/helpers.py b/wikijs/utils/helpers.py index 5a3af4c..ce5423c 100644 --- a/wikijs/utils/helpers.py +++ b/wikijs/utils/helpers.py @@ -45,7 +45,15 @@ def validate_url(url: str) -> bool: """ try: result = urlparse(url) - return all([result.scheme, result.netloc]) + # Check basic components exist + if not all([result.scheme, result.netloc]): + return False + + # Check for invalid characters (spaces, etc.) + if " " in url: + return False + + return True except Exception: return False @@ -103,7 +111,7 @@ def build_api_url(base_url: str, endpoint: str) -> str: return urljoin(api_base, endpoint.lstrip("/")) -def parse_wiki_response(response_data: Any) -> Dict[str, Any]: +def parse_wiki_response(response_data: Any) -> Any: """Parse Wiki.js API response data. Args: @@ -116,7 +124,7 @@ def parse_wiki_response(response_data: Any) -> Dict[str, Any]: APIError: If response indicates an error """ if not isinstance(response_data, dict): - return {"data": response_data} + return response_data # Check for error indicators if "error" in response_data: