@@ -316,10 +316,14 @@ def chat():
316
316
def analyze_folder ():
317
317
"""
318
318
Endpoint to analyze local source code
319
- Expects 'path' and optionaly an ignore list.
319
+ Expects 'path' and optionally an ignore list.
320
320
321
321
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
323
327
"""
324
328
325
329
# Get JSON data from the request
@@ -329,11 +333,21 @@ def analyze_folder():
329
333
path = data .get ('path' )
330
334
ignore = data .get ('ignore' , [])
331
335
332
- # Validate 'path' parameter
336
+ # Validate input parameters
333
337
if not path :
334
338
logging .error ("'path' is missing from the request." )
335
339
return jsonify ({"status" : "'path' is required." }), 400
336
340
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
+
337
351
proj_name = Path (path ).name
338
352
339
353
# Initialize the graph with the provided project name
@@ -345,8 +359,8 @@ def analyze_folder():
345
359
346
360
# Return response
347
361
response = {
348
- 'status' : 'success'
349
- }
350
-
362
+ 'status' : 'success' ,
363
+ 'project' : proj_name
364
+ }
351
365
return jsonify (response ), 200
352
366
0 commit comments