DevPath icon indicating copy to clipboard operation
DevPath copied to clipboard

[Bug]: Unhandled ValueError in recommender.py for invalid time_availability causes 500 Internal Server Error

Open bhavyapandiya29 opened this issue 6 months ago • 5 comments

Describe the bug In utils/recommender.py, the score_single_project function calls .index() on the TIME_AVAILABILITY list using the time_availability parameter from the user payload. Because validate_recommendation_inputs only checks if the input is non-empty (and doesn't check if it's a valid enum), sending an unrecognized time value causes a ValueError: '...' is not in list, crashing the server and returning a 500 Internal Server Error.

To Reproduce-

1.Send a POST request to /api/recommend with the payload: {"skills": "python", "level": "Beginner", "interest": "Data", "time": "unknown"} 2.The server will throw a ValueError at line 72 in utils/recommender.py and crash. Expected behavior: The input validation should check if time_availability is one of the allowed values (['low', 'medium', 'high']). If not, it should gracefully return a 400 Bad Request instead of crashing.

Proposed Solution: I can fix this by adding a check inside validate_recommendation_inputs in utils/recommender.py to ensure time_availability.lower() in ['low', 'medium', 'high'].

I am a GSSoC 2026 contributor and would love to fix this issue immediately. Please assign it to me!

bhavyapandiya29 avatar May 27 '26 14:05 bhavyapandiya29

@komalharshita I am a GSSoC 2026 contributor and would love to fix this issue immediately. Please assign it to me!

bhavyapandiya29 avatar May 27 '26 14:05 bhavyapandiya29

Thank you for opening your first issue in DevPath.

Please make sure to:

  • Read CONTRIBUTING.md
  • Wait for assignment before starting work
  • Follow repository guidelines carefully

Happy contributing.

github-actions[bot] avatar May 27 '26 14:05 github-actions[bot]

Hi, I would like to work on this issue under GSSoC'26. Please assign it to me.

mauliphad76 avatar May 28 '26 08:05 mauliphad76

Hi, I noticed this issue is linked with #659. I have reviewed the related files and would like to work on this specific bug/fix. Kindly let me know if I can proceed with a PR. @komalharshita

tapanya27 avatar May 28 '26 09:05 tapanya27

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions!

github-actions[bot] avatar Nov 28 '26 08:11 github-actions[bot]