-
Notifications
You must be signed in to change notification settings - Fork 70
Fixed working of github repo analysis page #172
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| from fastapi import APIRouter, HTTPException | ||
| from pydantic import BaseModel | ||
| from app.services.codegraph.repo_service import RepoService | ||
| import traceback | ||
|
|
||
| router = APIRouter(prefix="/api", tags=["repositories"]) | ||
|
|
||
| class RepoRequest(BaseModel): | ||
| repo_url: str | ||
|
|
||
| @router.post("/repo-stats") | ||
| async def analyze_repository(request: RepoRequest): | ||
| print(f" repo aa gayi : {request.repo_url}") | ||
|
|
||
| try: | ||
| result = await RepoService().index_repo(request.repo_url) | ||
| return { | ||
| "message": "Repository indexed successfully", | ||
| "repository": request.repo_url, | ||
| "stats": result | ||
| } | ||
| except Exception as e: | ||
| print(traceback.format_exc()) | ||
| raise HTTPException(status_code=500, detail=str(e)) from e | ||
|
Comment on lines
+15
to
+24
Contributor
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. Improve exception handling and logging. Two issues with the current exception handling:
Apply this diff to fix both issues: +import logging
+
+logger = logging.getLogger(__name__)
+
@router.post("/repo-stats")
async def analyze_repository(request: RepoRequest):
- print(f" repo aa gayi : {request.repo_url}")
+ logger.info(f"Repository analysis requested: {request.repo_url}")
try:
result = await RepoService().index_repo(request.repo_url)
return {
"message": "Repository indexed successfully",
"repository": request.repo_url,
"stats": result
}
+ except ValueError as e:
+ logger.warning(f"Invalid repository URL: {request.repo_url} - {str(e)}")
+ raise HTTPException(status_code=400, detail=str(e)) from e
except Exception as e:
- print(traceback.format_exc())
+ logger.exception(f"Failed to index repository: {request.repo_url}")
raise HTTPException(status_code=500, detail=str(e)) from eNote: You can also remove the
🧰 Tools🪛 Ruff (0.14.4)17-21: Consider moving this statement to an (TRY300) 🤖 Prompt for AI Agents |
||
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.
Replace debug print with proper logging.
Debug print statements should not appear in production code and won't be captured by centralized logging systems.
Apply this diff to use proper logging:
🤖 Prompt for AI Agents