GET /u/by-external/{id}.json returns HTML on 404

The 404 response for /u/{username}.json returns JSON as expected:

{"errors":["The requested URL or resource could not be found."],"error_type":"not_found"}

However, /u/by-external/{external_id}.json doesn’t have the same behaviour. It returns JSON on success, but HTML on 404 (and I would assume for other errors as well), confusing my JSON parser.

1 Like

@eviltrout perhaps this is one route that was missed in the rename?

This is unrelated to the path change – by-external needs some hacks to recognize the format which NotFound was not respecting.

https://github.com/discourse/discourse/commit/3839206317bc78efd9f4872776d95c6a380f7323

(long term we should probably figure out a nicer way around those hacks)

5 Likes