# Buggy code
def handle_notification_request(bucket, method, data):
    response = Response()
    response.status_code = 200
    response._content = ""
    if method == "GET":
        # TODO check if bucket exists
        result = '<NotificationConfiguration xmlns="%s">' % XMLNS_S3
        if bucket in S3_NOTIFICATIONS:
            notif = S3_NOTIFICATIONS[bucket]
            for dest in NOTIFICATION_DESTINATION_TYPES:
                if dest in notif:
                    dest_dict = {
                        "%sConfiguration" % dest: {
                            "Id": uuid.uuid4(),
                            dest: notif[dest],
                            "Event": notif["Event"],
                            "Filter": notif["Filter"],
                        }
                    }
                    result += xmltodict.unparse(dest_dict, full_document=False)
        result += "</NotificationConfiguration>"
        response._content = result

    if method == "PUT":
        parsed = xmltodict.parse(data)
        notif_config = parsed.get("NotificationConfiguration")
        S3_NOTIFICATIONS.pop(bucket, None)
        for dest in NOTIFICATION_DESTINATION_TYPES:
            config = notif_config.get("%sConfiguration" % (dest))
            if config:
                events = config.get("Event")
                if isinstance(events, six.string_types):
                    events = [events]
                event_filter = config.get("Filter", {})
                # make sure FilterRule is an array
                s3_filter = _get_s3_filter(event_filter)
                if s3_filter and not isinstance(s3_filter.get("FilterRule", []), list):
                    s3_filter["FilterRule"] = [s3_filter["FilterRule"]]
                # create final details dict
                notification_details = {
                    "Id": config.get("Id"),
                    "Event": events,
                    dest: config.get(dest),
                    "Filter": event_filter,
                }
                # TODO: what if we have multiple destinations - would we overwrite the config?
                S3_NOTIFICATIONS[bucket] = clone(notification_details)
    return response


# Traceback (AttributeError)
2017-11-06T16:27:30:ERROR:localstack.services.generic_proxy: Error forwarding request: 'list' object has no attribute 'get' Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/localstack/services/generic_proxy.py", line 161, in forward
path=path, data=data, headers=forward_headers)
File "/usr/local/lib/python3.6/site-packages/localstack/services/s3/s3_listener.py", line 402, in forward_request
events = config.get('Event')
AttributeError: 'list' object has no attribute 'get'

# Fixed code
def handle_notification_request(bucket, method, data):
    response = Response()
    response.status_code = 200
    response._content = ""
    if method == "GET":
        # TODO check if bucket exists
        result = '<NotificationConfiguration xmlns="%s">' % XMLNS_S3
        if bucket in S3_NOTIFICATIONS:
            notifs = S3_NOTIFICATIONS[bucket]
            for notif in notifs:
                for dest in NOTIFICATION_DESTINATION_TYPES:
                    if dest in notif:
                        dest_dict = {
                            "%sConfiguration" % dest: {
                                "Id": uuid.uuid4(),
                                dest: notif[dest],
                                "Event": notif["Event"],
                                "Filter": notif["Filter"],
                            }
                        }
                        result += xmltodict.unparse(dest_dict, full_document=False)
        result += "</NotificationConfiguration>"
        response._content = result

    if method == "PUT":
        parsed = xmltodict.parse(data)
        notif_config = parsed.get("NotificationConfiguration")
        S3_NOTIFICATIONS[bucket] = []
        for dest in NOTIFICATION_DESTINATION_TYPES:
            config = notif_config.get("%sConfiguration" % (dest))
            configs = config if isinstance(config, list) else [config] if config else []
            for config in configs:
                events = config.get("Event")
                if isinstance(events, six.string_types):
                    events = [events]
                event_filter = config.get("Filter", {})
                # make sure FilterRule is an array
                s3_filter = _get_s3_filter(event_filter)
                if s3_filter and not isinstance(s3_filter.get("FilterRule", []), list):
                    s3_filter["FilterRule"] = [s3_filter["FilterRule"]]
                # create final details dict
                notification_details = {
                    "Id": config.get("Id"),
                    "Event": events,
                    dest: config.get(dest),
                    "Filter": event_filter,
                }
                S3_NOTIFICATIONS[bucket].append(clone(notification_details))
    return response