Skip to content

[Bug]: NameError crash on /api/recommend — VALID_INTERESTS is undefined #822

@jatingow

Description

@jatingow

What happened?

The core recommendation endpoint POST /api/recommend crashes with a
NameError on every request.

Expected: submitting the recommendation form returns matching projects.
Actual: the server throws a NameError and the user gets no results.

Root cause: validate_recommendation_inputs() in utils/recommender.py
references VALID_INTERESTS on line 229, but this constant is never
defined anywhere in the codebase. VALID_LEVELS and VALID_TIME_AVAILABILITY
are defined correctly right above it (lines 212–213), but VALID_INTERESTS
was simply never added.

Steps to reproduce

  1. Clone the repo and run the dev server: python app.py
  2. Open http://127.0.0.1:5000
  3. Enter any skill (e.g. "Python"), select Beginner / Web / Low
  4. Click "Get Recommendations"
  5. Server returns a 500 error

Expected behaviour

The function should validate the interest field against a list of allowed
values (the same way it validates level and time_availability) and return
an empty list [] when inputs are valid.

Area of the app affected

Recommendation results

Python version

3.13.12

Operating system

Windows 11

Relevant error output or logs

Before submitting

  • I searched existing issues and this has not been reported before.
  • I can reproduce this bug consistently with the steps above.
  • I am running the latest version of the main branch.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions