HTML response with 502 error from API end-point

No, and as there’s no explicit guarantees on the type of response for errors you shouldn’t just assume everything should be JSON.

Looks to me from the data you posted originally that the response declared that it wasn’t JSON, the response to your request specifically said it was text/html so if your app just assumes its JSON and errors when it isn’t, that’s on you. If the content type was erroneous then that’d be Twitchs fault, but you got what it said.

If you believe the service that is returning that reaponse is in error, then you should submit an issue on the twitchdev github so it can be tracked. If on the other hand the service is doing what its designed to do despite your app not gracefully handling it, the it would be a feature request to change the currently designed functionality of that service.

Again, please stop assuming that responses will always be JSON unless its explicitly guaranteed to do so. The intended responses will be JSON, as documented, but unexpected errors haven’t been explicitly guaranteed to be any specific format for all cases.

You are free to do whatever you like with your own code, even if it does go against best programming practices. While we are 3rd party devs, many of us have been working with this API for many years and some of us have worked for Twitch, so we’re trying to advise you on the best ways to properly submit feature requests or error reports as well as how you could handle such issues on your end and in the process develop better error handling to result in an overall better app design and reliability of your app. If you choose to take the advice of this community or not is up to you.