diff --git a/backend/app/api/v1/endpoints/auth.py b/backend/app/api/v1/endpoints/auth.py
index 93930bf..5a6adf0 100644
--- a/backend/app/api/v1/endpoints/auth.py
+++ b/backend/app/api/v1/endpoints/auth.py
@@ -42,8 +42,10 @@ async def github_callback_handler(request: Request, code: str = None, state: str
"""
# Verify state parameter to prevent CSRF attacks
stored_state = request.session.get('oauth_state')
+ print(f"DEBUG: Received state: {state}, Stored state: {stored_state}")
if not state or not stored_state or state != stored_state:
request.session.pop('oauth_state', None) # Clean up state
+ print(f"DEBUG: State mismatch - received: {state}, stored: {stored_state}")
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail="Invalid state parameter. CSRF check failed."
diff --git a/backend/app/main.py b/backend/app/main.py
index f1608ae..85b003d 100644
--- a/backend/app/main.py
+++ b/backend/app/main.py
@@ -1,3 +1,4 @@
+import os
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from starlette.middleware.sessions import SessionMiddleware
@@ -15,11 +16,11 @@
app.add_middleware(
SessionMiddleware,
secret_key=settings.SECRET_KEY,
- # --- Optional Session Cookie Parameters (consider for production) ---
- # session_cookie="your_app_session", # Customize the cookie name
- # max_age=7 * 24 * 60 * 60, # Example: Cookie expires after 7 days
- # same_site="lax", # Or "strict" for more security, but test carefully
- # https_only=True, # Recommended: Send cookie only over HTTPS
+ # --- Session Cookie Parameters ---
+ session_cookie="issuematch_session", # Customize the cookie name
+ max_age=7 * 24 * 60 * 60, # Example: Cookie expires after 7 days
+ same_site="lax", # Use lax for localhost development to avoid CSRF issues
+ https_only=False, # No HTTPS in development
)
@@ -32,7 +33,6 @@
]
# In production, allow requests from any origin
-import os
if os.environ.get("RENDER", False):
origins = ["*"] # Allow all origins in production
@@ -62,14 +62,16 @@ async def read_root():
# --- Optional: Startup/Shutdown Event Handlers ---
# These functions can run code when the server starts or stops.
# Useful for loading resources (like a FAISS index) or cleaning up.
-# @app.on_event("startup")
-# async def startup_event():
-# """
-# Code to run when the application starts up.
-# Example: Load ML models, FAISS index, connect to databases.
-# """
-# print("Backend server starting up...")
-# # load_faiss_index() # Example placeholder
+from .services.faiss_search import load_model
+
+@app.on_event("startup")
+async def startup_event():
+ """
+ Code to run when the application starts up.
+ Example: Load ML models, FAISS index, connect to databases.
+ """
+ print("Backend server starting up...")
+ load_model()
# @app.on_event("shutdown")
# async def shutdown_event():
diff --git a/backend/app/services/faiss_search.py b/backend/app/services/faiss_search.py
index afab5f3..2cee421 100644
--- a/backend/app/services/faiss_search.py
+++ b/backend/app/services/faiss_search.py
@@ -17,15 +17,18 @@
# Global variables
model = None
-# Initialize the model
-try:
- logger.info(f"Loading sentence transformer model: {MODEL_NAME}")
- model = SentenceTransformer(MODEL_NAME)
- logger.info("Model loaded successfully")
-except Exception as e:
- logger.error(f"Error loading model: {str(e)}")
- model = None
+def load_model():
+ global model
+ if model is None:
+ try:
+ logger.info(f"Loading sentence transformer model: {MODEL_NAME}")
+ model = SentenceTransformer(MODEL_NAME)
+ logger.info("Model loaded successfully")
+ except Exception as e:
+ logger.error(f"Error loading model: {str(e)}")
+ model = None
+load_model()
def fetch_github_issues(keywords: List[str], top_k: int = TOP_PER_KEYWORD, github_token: Optional[str] = None) -> List[
Dict[str, Any]]:
@@ -48,15 +51,16 @@ def fetch_github_issues(keywords: List[str], top_k: int = TOP_PER_KEYWORD, githu
all_issues = []
for keyword in keywords:
- query = f'label:"{keyword}"+state:open+type:issue'
+ # Search for keyword in title, body, and comments instead of just labels
+ query = f'{keyword}+state:open+type:issue'
url = f"https://api.github.com/search/issues?q={query}&per_page={top_k}"
- # logger.info(f"Fetching issues for keyword: {keyword}")
+ logger.info(f"Fetching issues for keyword: {keyword}")
response = requests.get(url, headers=headers)
if response.status_code == 200:
items = response.json().get('items', [])
- # logger.info(f"Found {len(items)} issues for keyword: {keyword}")
+ logger.info(f"Found {len(items)} issues for keyword: {keyword}")
all_issues.extend(items[:top_k]) # Take top N only
else:
logger.error(f"Error for keyword: {keyword}, Status Code: {response.status_code}")
@@ -199,7 +203,7 @@ def get_top_matched_issues(
global model
try:
- # logger.info(f"Getting top matched issues for query: {query_text[:100]}...")
+ logger.info(f"Getting top matched issues for query: {query_text[:100]}...")
# Check if model is loaded
if model is None:
@@ -224,13 +228,19 @@ def get_top_matched_issues(
# Fetch issues
issues = fetch_github_issues(search_keywords, top_k=TOP_PER_KEYWORD, github_token=github_token)
+ # Fallback: If no issues found with specific keywords, try with general programming keywords
+ if not issues:
+ logger.warning("No issues fetched with specific keywords, trying fallback keywords")
+ fallback_keywords = ["python", "javascript", "java", "react", "node", "good first issue"]
+ issues = fetch_github_issues(fallback_keywords, top_k=TOP_PER_KEYWORD, github_token=github_token)
+
if not issues:
- logger.warning("No issues fetched")
+ logger.warning("No issues fetched even with fallback keywords")
return {
"recommendations": [],
"issues_fetched": 0,
"issues_indexed": 0,
- "message": "No issues found for the given keywords"
+ "message": "No issues found for the given keywords. Try adjusting your search criteria or check back later."
}
# Prepare issue texts for embedding
diff --git a/frontend/app/skills/page.tsx b/frontend/app/skills/page.tsx
index b889250..07b4487 100644
--- a/frontend/app/skills/page.tsx
+++ b/frontend/app/skills/page.tsx
@@ -136,7 +136,7 @@ export default function SkillsPage() {
// Loading state - show while checking auth or loading user data
if (loading || authLoading) {
return (
-