• Andrew Fontaine's avatar
    Fall back to avaiable scope if scope is invalid · b9da1851
    Andrew Fontaine authored
    On environments, only 2 scopes are valid: available and stopped. If an
    invalid scope is passed via the query params, the controller attempted
    to use it and would return a 500 error.
    
    This behaviour is still useful for the JSON API, and so we only fetch
    the environments if the format is JSON.
    
    However, as the environments are fetched via API after the HTML is
    returned, there's no need to query the environments when the format is
    HTML, meaning no need to use the scope. This stops invalid query
    params (like ?scope=foo) from returning a 500 error. To stop the
    resultant API calls from failing, we can check to see if the requested
    scope is valid. If it is not, default to the available scope.
    
    Changelog: fixed
    b9da1851
constants.js 980 Bytes