GET /api/events/<id>/category returns 500 for an unknown category id #58

Open
opened 2026-10-03 19:44:41 +00:00 by jalenluorion · 0 comments
Member

What's wrong
The <id> in this route is a category id, not an event id (/<int:category_id>/category). For an id with no category, get_category_by_id() returns None and category_to_dict(None) raises "'NoneType' object has no attribute 'id'", so the route returns 500.

How to reproduce

curl -i http://localhost:5001/api/events/999999/category

Returns 500 {"error": "Internal server error"}. An existing category id returns 200.

Expected
404 {"error": "Category not found"}.

Where to look

  • api/app/api/events.py get_event_category() (L958-968).
  • api/app/models/category.py get_category_by_id() and category_to_dict().
  • Line numbers are from main at 2c5f2e9.

Done when

  • unknown id returns 404 with a message
  • test in api/tests/api/test_error_responses.py for an unknown id (404) and world["cat1"] (200)
**What's wrong** The `<id>` in this route is a category id, not an event id (`/<int:category_id>/category`). For an id with no category, `get_category_by_id()` returns None and `category_to_dict(None)` raises "'NoneType' object has no attribute 'id'", so the route returns 500. **How to reproduce** ``` curl -i http://localhost:5001/api/events/999999/category ``` Returns 500 `{"error": "Internal server error"}`. An existing category id returns 200. **Expected** 404 `{"error": "Category not found"}`. **Where to look** - `api/app/api/events.py` `get_event_category()` (L958-968). - `api/app/models/category.py` `get_category_by_id()` and `category_to_dict()`. - Line numbers are from main at 2c5f2e9. **Done when** - [ ] unknown id returns 404 with a message - [ ] test in `api/tests/api/test_error_responses.py` for an unknown id (404) and `world["cat1"]` (200)
jalenluorion added this to the Phase 1 milestone 2026-10-03 19:44:41 +00:00
jalenluorion added this to the CMUCal project 2026-10-03 19:45:09 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
ScottyLabs/cal#58
No description provided.