Skip to content

/get_thresholds returns 500 due to route/helper argument mismatch #138

@aaronaco

Description

@aaronaco

Description (Actual Behavior)

The documented GET /get_thresholds endpoint returns 500 Internal Server Error when called from Swagger UI.

Swagger documents the required query parameter as prompts, but app.py reads prompt. The route then calls:

recommendation_handler.get_thresholds(prompt, prompt_json, api_url, headers)

while the helper signature is:

get_thresholds(prompts, prompt_json, embedding_fn=None)

This causes the endpoint to fail with a TypeError because the route passes four arguments to a helper that accepts two or three.

Expected Behavior

GET /get_thresholds should accept one or more prompt samples through the documented prompts query parameter and return threshold recommendations as JSON.

For missing or empty prompt samples, the endpoint should return a clear client error instead of a server error.

Possible Fix

Update the route to:

  • read the documented prompts query parameter
  • construct an embedding function
  • call recommendation_handler.get_thresholds(prompts, prompt_json, embedding_fn)
  • return a JSON 400 response for missing or empty input
  • update Swagger to document how multiple prompts values should be supplied

Steps to Reproduce

  1. Start the server:
python app.py
  1. Open Swagger UI:
http://127.0.0.1:8080/swagger
  1. Execute GET /get_thresholds with:
prompts = Act as a data scientist. Help me make this project more inclusive.
  1. Observe 500 Internal Server Error.

Equivalent curl:

curl -X GET \
  'http://127.0.0.1:8080/get_thresholds?prompts=Act%20as%20a%20data%20scientist.%20Help%20me%20make%20this%20project%20more%20inclusive.' \
  -H 'accept: */*'

Context

The endpoint is documented in Swagger as “Function that recommends thresholds given an array of prompts,” but it is currently unusable through the documented request shape.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions