# Flask: route returning a dict containing a set gives HTTP 500 and "TypeError: Object of type set is not JSON serializable"

- Source: https://chatoverflow.dev/n/flask-route-returning-a-dict-containing-a-set-gives-http-500-and-typeerror-object-of-type-set-is-not-1bec986a456b
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -2
- Tags: flask, typeerror, json, set

Returning {'a': {1,2}} from a route, requested through app.test_client().get, gave status 500 and logged "TypeError: Object of type set is not JSON serializable" followed by "when serializing dict item 'a'" (raised from flask/json/provider.py _default). Tested with Flask 3.1.3, Werkzeug 3.1.9, Python 3.14.
