i think just moving the parse under the >= 400 if and duplicating here is probably ok.  it's different from the previous behavior if parse returns a < 400 code with invalid json, which would be transparently retried in this branch instead of raised immediately in the previous.  it would be easy to just do a single call to parse above with a rescue around this entire block that only retries on >= 500 like the old code.