Tasktype endpoint should gracefully handle malformed api_constraints values
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 48/100
Research direction
Start in src/routers/openml/tasktype.py at the GET /tasktype/{task_type_id} entry point and inspect how api_constraints is parsed. Reproduce the endpoint with malformed JSON, a dict-like value, and valid JSON without data_type. Done means the endpoint returns a stable response, accepts string and dict values, and includes input[].data_type only when available.
Written by the indexing model from the issue text.
Description
Describe the bug
The /tasktype/{task_type_id} endpoint is not robust to unexpected api_constraints values.
In src/routers/openml/tasktype.py, the current parsing assumes a valid JSON string containing data_type. If api_constraints is malformed JSON, already a dict, or missing data_type, the endpoint may fail or behave inconsistently.
To Reproduce
Minimal reproducible setup (data-level reproduction):
- Ensure a task type exists with at least one input row in the DB.
- Set
api_constraintsfor that input to malformed JSON, for example:"{bad json"
- Call:
GET /tasktype/<task_type_id>
Also test with:
api_constraintsalready stored as a dict/object-like value (if DB layer returns dict)api_constraintsvalid JSON but withoutdata_type, e.g.{"foo":"bar"}
Expected behavior
- The endpoint should return a stable response and should not crash.
- It should accept both legacy JSON strings and dict-like values.
- It should include
input[].data_typeonly whendata_typeis present. - Malformed JSON in
api_constraintsshould be ignored gracefully for that field.
Additional context
Proposed fix is to make parsing defensive:
- parse string values via
json.loadsinsidetry/except json.JSONDecodeError - accept dict values directly
- set
data_typeconditionally using safe lookup
- Dominant language
- Python
- Stars
- 16
- Forks
- 50
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from openml/server-api
-
behavior
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
openml/server-api#337 · 1 comment ·
-
proposal
openml/server-api#375 · 2 comments · 1 assignee ·
-
openml/server-api#374 · 2 comments · 1 assignee ·
-
openml/server-api#373 · 1 assignee ·
-
openml/server-api#372 · 1 assignee ·
All issues in openml/server-api
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
stephrobert/dsoxlab#238 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
sublimehq/package_control#1780 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
nwg-piotr/nwg-displays#145 ·