Is there a better flow for returning the response?
I think this generally looks pretty good.  I would consider two things:


First I don't like the "internal" option here which leads to mixed return values.  Have you considered having getSessionNameSpaceInternal() which would call this method and extract the desired return value from the JsonResponse?
Doing the above would allow you to directly return from catch block s like this:

} catch (ClientException $e) {
    return new JsonResponse(
        'The endpoint responded with a ' . $e-&gt;getCode(),
        $e-&gt;getCode()
    );
} catch (\Exception $e) {
    return new JsonResponse( $e-&gt;getMessage(), $e-&gt;getStatusCode() );
}