Skip to content

Commit 3de17bb

Browse files
committed
improved process local dir endpoint
1 parent 69142bb commit 3de17bb

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

api/index.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -316,10 +316,14 @@ def chat():
316316
def analyze_folder():
317317
"""
318318
Endpoint to analyze local source code
319-
Expects 'path' and optionaly an ignore list.
319+
Expects 'path' and optionally an ignore list.
320320
321321
Returns:
322-
Status code
322+
JSON response with status and error message if applicable
323+
Status codes:
324+
200: Success
325+
400: Invalid input
326+
500: Internal server error
323327
"""
324328

325329
# Get JSON data from the request
@@ -329,11 +333,21 @@ def analyze_folder():
329333
path = data.get('path')
330334
ignore = data.get('ignore', [])
331335

332-
# Validate 'path' parameter
336+
# Validate input parameters
333337
if not path:
334338
logging.error("'path' is missing from the request.")
335339
return jsonify({"status": "'path' is required."}), 400
336340

341+
# Validate path exists and is a directory
342+
if not os.path.isdir(path):
343+
logging.error(f"Path '{path}' does not exist or is not a directory")
344+
return jsonify({"status": "Invalid path: must be an existing directory"}), 400
345+
346+
# Validate ignore list contains valid paths
347+
if not isinstance(ignore, list):
348+
logging.error("'ignore' must be a list of paths")
349+
return jsonify({"status": "'ignore' must be a list of paths"}), 400
350+
337351
proj_name = Path(path).name
338352

339353
# Initialize the graph with the provided project name
@@ -345,8 +359,8 @@ def analyze_folder():
345359

346360
# Return response
347361
response = {
348-
'status': 'success'
349-
}
350-
362+
'status': 'success',
363+
'project': proj_name
364+
}
351365
return jsonify(response), 200
352366

0 commit comments

Comments
 (0)