-
Notifications
You must be signed in to change notification settings - Fork 1
fix(CODEWIKI-005): CU-86akbhhru 6 review findings across 4 files #52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
94d2095
c56a940
4caa35f
07138b5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ | |
| """ | ||
|
|
||
| import hashlib | ||
| import logging | ||
| from datetime import datetime, timedelta | ||
| from pathlib import Path | ||
| from typing import Optional, Dict | ||
|
|
@@ -12,6 +13,8 @@ | |
| from .config import WebAppConfig | ||
| from codewiki.src.utils import file_manager | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| class CacheManager: | ||
| """Manages documentation cache.""" | ||
|
|
@@ -38,7 +41,13 @@ def load_cache_index(self): | |
| last_accessed=datetime.fromisoformat(value['last_accessed']) | ||
| ) | ||
| except Exception as e: | ||
| print(f"Error loading cache index: {e}") | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π cache_manager.py uses print() instead of the required logging module Added π€ Prompt for AI agentsfix confidence: π’ 90 high β react π/π to teach the reviewer |
||
| logger.error(f"Error loading cache index: {e}, backing up corrupted file") | ||
| try: | ||
| backup_file = self.cache_dir / f"cache_index.json.corrupted.{int(datetime.now().timestamp())}" | ||
| index_file.rename(backup_file) | ||
| except Exception as backup_error: | ||
| logger.error(f"Error backing up corrupted cache index: {backup_error}") | ||
| self.cache_index = {} | ||
|
|
||
| def save_cache_index(self): | ||
| """Save cache index to disk.""" | ||
|
Comment on lines
41
to
53
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π field_manager.load_json exceptions in CacheManager are silently swallowed, corrupting cache index recovery In π€ Prompt for AI agentsfix confidence: π΄ 40 low β review closely β react π/π to teach the reviewer |
||
|
|
@@ -56,7 +65,7 @@ def save_cache_index(self): | |
|
|
||
| file_manager.save_json(data, index_file) | ||
| except Exception as e: | ||
| print(f"Error saving cache index: {e}") | ||
| logger.error(f"Error saving cache index: {e}") | ||
|
|
||
| def get_repo_hash(self, repo_url: str) -> str: | ||
| """Generate hash for repository URL.""" | ||
|
|
@@ -116,4 +125,4 @@ def cleanup_expired_cache(self): | |
| del self.cache_index[repo_hash] | ||
|
|
||
| if expired_entries: | ||
| self.save_cache_index() | ||
| self.save_cache_index() | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,13 +3,17 @@ | |
| GitHub repository processing utilities. | ||
| """ | ||
|
|
||
| import logging | ||
| import os | ||
| import shutil | ||
| import subprocess | ||
| from typing import Dict | ||
| from urllib.parse import urlparse | ||
|
|
||
| from .config import WebAppConfig | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| class GitHubRepoProcessor: | ||
| """Handles GitHub repository processing.""" | ||
|
|
@@ -66,7 +70,7 @@ def clone_repository(clone_url: str, target_dir: str, commit_id: str = None) -> | |
| ], capture_output=True, text=True, timeout=WebAppConfig.CLONE_TIMEOUT) | ||
|
|
||
| if result.returncode != 0: | ||
| print(f"Error cloning repository: {result.stderr}") | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π github_processor.py uses print() for error output instead of logging Replaced all π€ Prompt for AI agentsfix confidence: π’ 90 high β react π/π to teach the reviewer |
||
| logger.error(f"Error cloning repository: {result.stderr}") | ||
| return False | ||
|
|
||
| # Checkout specific commit | ||
|
Comment on lines
70
to
76
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π GitHubRepoProcessor.clone_repository leaves target_dir/.git present after full clone even on checkout failure, and swallows all exceptions broadly In π€ Prompt for AI agentsfix confidence: π΄ 55 low β review closely β react π/π to teach the reviewer |
||
|
|
@@ -75,7 +79,9 @@ def clone_repository(clone_url: str, target_dir: str, commit_id: str = None) -> | |
| ], cwd=target_dir, capture_output=True, text=True, timeout=30) | ||
|
|
||
| if result.returncode != 0: | ||
| print(f"Error checking out commit {commit_id}: {result.stderr}") | ||
| logger.error(f"Error checking out commit {commit_id}: {result.stderr}") | ||
| if os.path.isdir(target_dir): | ||
| shutil.rmtree(target_dir, ignore_errors=True) | ||
| return False | ||
| else: | ||
| # Clone repository with shallow depth (default behavior) | ||
|
|
@@ -84,10 +90,12 @@ def clone_repository(clone_url: str, target_dir: str, commit_id: str = None) -> | |
| ], capture_output=True, text=True, timeout=WebAppConfig.CLONE_TIMEOUT) | ||
|
|
||
| if result.returncode != 0: | ||
| print(f"Error cloning repository: {result.stderr}") | ||
| logger.error(f"Error cloning repository: {result.stderr}") | ||
| return False | ||
|
|
||
| return True | ||
| except Exception as e: | ||
| print(f"Error cloning repository: {e}") | ||
| return False | ||
| logger.error(f"Error cloning repository: {e}") | ||
| if os.path.isdir(target_dir): | ||
| shutil.rmtree(target_dir, ignore_errors=True) | ||
| return False | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ | |
| """ | ||
|
|
||
| import argparse | ||
| import logging | ||
| import sys | ||
| from pathlib import Path | ||
| from typing import Dict, Optional | ||
|
|
@@ -25,6 +26,8 @@ | |
| from .templates import DOCS_VIEW_TEMPLATE | ||
| from codewiki.src.utils import file_manager | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
| app = FastAPI(title="Documentation Server", description="Simple documentation server for hosting markdown documentation folders") | ||
|
|
||
| # Global variables to store configuration | ||
|
|
@@ -55,13 +58,13 @@ def load_module_tree(docs_folder: Path) -> Optional[Dict]: | |
| """Load the module tree structure from module_tree.json.""" | ||
| tree_file = docs_folder / "module_tree.json" | ||
| if not tree_file.exists(): | ||
| print(f"Warning: module_tree.json not found in {docs_folder}") | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 𦩠π visualise_docs.py uses print() throughout instead of logging Replaced all π€ Prompt for AI agentsfix confidence: π‘ 85 medium β react π/π to teach the reviewer |
||
| logger.warning(f"module_tree.json not found in {docs_folder}") | ||
| return None | ||
|
|
||
| try: | ||
| return file_manager.load_json(tree_file) | ||
| except Exception as e: | ||
| print(f"Error loading module_tree.json: {e}") | ||
| logger.error(f"Error loading module_tree.json: {e}") | ||
| return None | ||
|
|
||
|
|
||
|
|
@@ -219,17 +222,17 @@ def main(): | |
| # Validate docs folder | ||
| docs_folder = Path(args.docs_folder) | ||
| if not docs_folder.exists(): | ||
| print(f"Error: Documentation folder '{docs_folder}' does not exist") | ||
| logger.error(f"Documentation folder '{docs_folder}' does not exist") | ||
| sys.exit(1) | ||
|
|
||
| if not docs_folder.is_dir(): | ||
| print(f"Error: '{docs_folder}' is not a directory") | ||
| logger.error(f"'{docs_folder}' is not a directory") | ||
| sys.exit(1) | ||
|
|
||
| # Check for overview.md | ||
| overview_file = docs_folder / "overview.md" | ||
| if not overview_file.exists(): | ||
| print(f"Warning: overview.md not found in '{docs_folder}'") | ||
| logger.warning(f"overview.md not found in '{docs_folder}'") | ||
|
|
||
| # Set global variables and environment variable for uvicorn reload | ||
| global DOCS_FOLDER, MODULE_TREE | ||
|
|
@@ -240,16 +243,16 @@ def main(): | |
| import os | ||
| os.environ['DOCS_FOLDER'] = DOCS_FOLDER | ||
|
|
||
| print(f"π Starting documentation server...") | ||
| print(f"π Documentation folder: {DOCS_FOLDER}") | ||
| print(f"π Server running at: http://{args.host}:{args.port}") | ||
| print(f"π Main page: overview.md") | ||
| logger.info(f"π Starting documentation server...") | ||
| logger.info(f"π Documentation folder: {DOCS_FOLDER}") | ||
| logger.info(f"π Server running at: http://{args.host}:{args.port}") | ||
| logger.info(f"π Main page: overview.md") | ||
|
|
||
| if MODULE_TREE: | ||
| modules_count = len(MODULE_TREE) | ||
| print(f"ποΈ Found {modules_count} main modules in module_tree.json") | ||
| logger.info(f"ποΈ Found {modules_count} main modules in module_tree.json") | ||
|
|
||
| print("\nPress Ctrl+C to stop the server") | ||
| logger.info("Press Ctrl+C to stop the server") | ||
|
|
||
| try: | ||
| import uvicorn | ||
|
|
@@ -261,8 +264,8 @@ def main(): | |
| log_level="debug" if args.debug else "info" | ||
| ) | ||
| except KeyboardInterrupt: | ||
| print("\nπ Server stopped") | ||
| logger.info("π Server stopped") | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
| main() | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
𦩠π print() used for diagnostic output inside codewiki/src/be module instead of logging
Added
import loggingandlogger = logging.getLogger(__name__)at module top, and replaced everyprint(...)call acrossload_flamingo_guidelines,sanitize_problematic_patterns,sanitize_and_escape_format_braces,load_custom_instructions, andload_validation_ruleswith appropriatelogger.info/logger.debug/logger.warningcalls (info for normal load status, debug for the brace-count/sanitization trace output, warning for missing-file/exception cases), fully removing print() usage per CODEWIKI-005 while preserving message text and call sites unchanged.π€ Prompt for AI agents
fix confidence: π‘ 88 medium β react π/π to teach the reviewer