# Steps to reproduce

* Start `localstack` (version 0.10.3).
* Don't create any lambda functions.
* Run:

```sh
AWS_ACCESS_KEY_ID='a' AWS_SECRET_ACCESS_KEY='b' \
aws lambda invoke \
  --function-name 'my-func' \
  --qualifier='qual' \
  --endpoint http://localhost:4574 test.out
```

* Expected behaviour — a `ResourceNotFoundException` from `aws-cli`.
* Actual behaviour — `An error occurred (500) when calling the Invoke operation` message and a 500 response.

This bug only appears if a `qualifier` is included in the request.
""" Create the final response for the given invocation result """
        if isinstance(result, Response):
            return result
        details = {
            'StatusCode': status_code,
            'Payload': result,
            'Headers': {}
        }
        if isinstance(result, dict):
            for key in ('StatusCode', 'Payload', 'FunctionError'):
                if result.get(key):
                    details[key] = result[key]
        
        payload = details['Payload']
        if payload and isinstance(payload, (str, bytes)) and payload[0] in ('[', '{', '"'):
            try:
                details['Payload'] = json.loads(details['Payload'])
            except Exception:
                pass
        
        if details.get('FunctionError'):
            details['Headers']['X-Amz-Function-Error'] = str(details['FunctionError'])
        
        response_obj = details['Payload']
        if isinstance(response_obj, (dict, list, bool)) or is_number(response_obj):