Repository: MindscapeHQ/raygun4py

Issue:
AttributeError: 'NoneType' object has no attribute 'set_user'
Recently upgraded from 3.1.6 to 4.1.0 and it looks like `RaygunMessageBuilder.set_request_details` is returning `None` in some situations, causing exception sending to fail with an `AttributeError: 'NoneType' object has no attribute 'set_user'`

https://github.com/MindscapeHQ/raygun4py/blob/v4.1.0/python3/raygun4py/raygunprovider.py#L124-L125
https://github.com/MindscapeHQ/raygun4py/blob/v4.1.0/python3/raygun4py/raygunmsgs.py#L92-L97

Stacktrace:
```py
/usr/local/lib/python3.6/site-packages/raygun4py/raygunprovider.py:96: in send_exception
    message = self._create_message(errorMessage, tags, custom_data, http_request, extra_environment_data)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <raygun4py.raygunprovider.RaygunSender object at 0x7f6dbbbf0320>, raygunExceptionMessage = <raygun4py.raygunmsgs.RaygunErrorMessage object at 0x7f6dbbbccf60>
tags = ['django-novars'], user_custom_data = None
http_request = {'form': {}, 'headers': {'CONTENT_TYPE': 'application/octet-stream', 'HTTP_COOKIE': '', 'PATH_INFO': '/', 'QUERY_STRING': '', ...}, 'hostName': 'testserver', 'httpMethod': 'GET', ...}
extra_environment_data = {'frameworkVersion': '2.1.2'}

    def _create_message(self, raygunExceptionMessage, tags, user_custom_data, http_request, extra_environment_data):
        return raygunmsgs.RaygunMessageBuilder().new() \
            .set_machine_name(socket.gethostname()) \
            .set_version(self.userversion) \
            .set_client_details() \
            .set_exception_details(raygunExceptionMessage) \
            .set_environment_details(extra_environment_data) \
            .set_tags(tags) \
            .set_customdata(user_custom_data) \
>           .set_request_details(http_request) \
            .set_user(self.user) \
            .build()
E       AttributeError: 'NoneType' object has no attribute 'set_user'

/usr/local/lib/python3.6/site-packages/raygun4py/raygunprovider.py:124: AttributeError
```

Discussion:

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9a8e114..d80a3f8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 4.2.2 (23/01/2019):
+Bugfixes
+  - Fix `set_request_details` builder method not returning self causing it to be unchainable
+
 ## 4.2.1 (18/12/2018):
 Bugfixes
   - Set version correctly in crash report sent to Raygun API ([#78](https://github.com/MindscapeHQ/raygun4py/pull/79))
diff --git a/python2/raygun4py/version.py b/python2/raygun4py/version.py
index 53fb41b..3cd825b 100644
--- a/python2/raygun4py/version.py
+++ b/python2/raygun4py/version.py
@@ -2,4 +2,4 @@
 # 1) we don't load dependencies by storing it in __init__.py
 # 2) we can import it in setup.py for the same reason
 # 3) we can import it into your module module
-__version__ = '4.2.1'
+__version__ = '4.2.2'
diff --git a/python3/raygun4py/raygunmsgs.py b/python3/raygun4py/raygunmsgs.py
index c419558..6d3c318 100644
--- a/python3/raygun4py/raygunmsgs.py
+++ b/python3/raygun4py/raygunmsgs.py
@@ -97,6 +97,8 @@ class RaygunMessageBuilder(object):
         rg_request_details = http_utilities.build_wsgi_compliant_request(request)
         self.raygunMessage.details['request'] = rg_request_details
 
+        return self
+
 
     def set_version(self, version):
         self.raygunMessage.details['version'] = version
diff --git a/python3/raygun4py/version.py b/python3/raygun4py/version.py
index 53fb41b..3cd825b 100644
--- a/python3/raygun4py/version.py
+++ b/python3/raygun4py/version.py
@@ -2,4 +2,4 @@
 # 1) we don't load dependencies by storing it in __init__.py
 # 2) we can import it in setup.py for the same reason
 # 3) we can import it into your module module
-__version__ = '4.2.1'
+__version__ = '4.2.2'


Test patch:
diff --git a/python3/tests/test_raygunmsgs.py b/python3/tests/test_raygunmsgs.py
index 2f0b3e0..be16405 100644
--- a/python3/tests/test_raygunmsgs.py
+++ b/python3/tests/test_raygunmsgs.py
@@ -109,6 +109,12 @@ class TestRaygunMessageBuilder(unittest.TestCase):
         self.assertEqual(self.builder.raygunMessage.details['request']['headers']['Referer'],
                         "https://www.google.com/")
 
+    def test_set_request_details_allows_chaining(self):
+        self.builder \
+                .set_request_details(self.raw_wsgi_request) \
+                .set_tags(['foo', 'bar'])
+
+
 class TestRaygunErrorMessage(unittest.TestCase):
     class GrandchildError(Exception):
         pass