# Buggy code
def _ParseRecord(self, parser_mediator, file_object):
    """Parses an event record.

    Args:
      parser_mediator (ParserMediator): mediates interactions between parsers
          and other components, such as storage and dfvfs.
      file_object (dfvfs.FileIO): file-like object.

    Raises:
      ParseError: if the event record cannot be read.
    """
    header_record_offset = file_object.tell()

    # Check the header token type before reading the token data to prevent
    # variable size tokens to consume a large amount of memory.
    token_type = self._ParseTokenType(file_object, header_record_offset)
    if token_type not in self._HEADER_TOKEN_TYPES:
        raise errors.ParseError(
            "Unsupported header token type: 0x{0:02x}".format(token_type)
        )

    token_type, token_data = self._ParseToken(file_object, header_record_offset)

    if token_data.format_version != 11:
        raise errors.ParseError(
            "Unsupported format version type: {0:d}".format(token_data.format_version)
        )

    timestamp = token_data.microseconds + (
        token_data.timestamp * definitions.MICROSECONDS_PER_SECOND
    )

    event_type = token_data.event_type
    header_record_size = token_data.record_size
    record_end_offset = header_record_offset + header_record_size

    event_tokens = []
    return_token_values = None

    file_offset = file_object.tell()
    while file_offset < record_end_offset:
        token_type, token_data = self._ParseToken(file_object, file_offset)
        if not token_data:
            raise errors.ParseError(
                "Unsupported token type: 0x{0:02x}".format(token_type)
            )

        file_offset = file_object.tell()

        if token_type == self._TOKEN_TYPE_AUT_TRAILER:
            break

        token_type_string = self._TOKEN_TYPES.get(token_type, "UNKNOWN")
        token_values = self._FormatTokenData(token_type, token_data)
        event_tokens.append({token_type_string: token_values})

        if token_type in (self._TOKEN_TYPE_AUT_RETURN32, self._TOKEN_TYPE_AUT_RETURN64):
            return_token_values = token_values

    if token_data.signature != self._TRAILER_TOKEN_SIGNATURE:
        raise errors.ParseError("Unsupported signature in trailer token.")

    if token_data.record_size != header_record_size:
        raise errors.ParseError(
            "Mismatch of event record size between header and trailer token."
        )

    event_data = BSMEventData()
    event_data.event_type = event_type
    event_data.extra_tokens = event_tokens
    event_data.offset = header_record_offset
    event_data.record_length = header_record_size
    event_data.return_value = return_token_values

    date_time = dfdatetime_posix_time.PosixTimeInMicroseconds(timestamp=timestamp)
    event = time_events.DateTimeValuesEvent(
        date_time, definitions.TIME_DESCRIPTION_CREATION
    )
    parser_mediator.ProduceEventWithEventData(event, event_data)


# Traceback (ValueError)
Traceback (most recent call last):
File "plaso/tools/log2timeline.py", line 97, in <module>
if not Main():
File "plaso/tools/log2timeline.py", line 72, in Main
tool.ExtractEventsFromSources()
File "plaso/plaso/cli/log2timeline_tool.py", line 448, in ExtractEventsFromSources
worker_memory_limit=self._worker_memory_limit)
File "plaso/plaso/multi_processing/task_engine.py", line 812, in ProcessSources
self._ProcessSources(source_path_specs, storage_writer)
File "plaso/plaso/multi_processing/task_engine.py", line 343, in _ProcessSources
self._ScheduleTasks(storage_writer)
File "plaso/plaso/multi_processing/task_engine.py", line 449, in _ScheduleTasks
self._MergeTaskStorage(storage_writer)
File "plaso/plaso/multi_processing/task_engine.py", line 256, in _MergeTaskStorage
maximum_number_of_containers=self._MAXIMUM_NUMBER_OF_CONTAINERS)
File "plaso/plaso/storage/sqlite/merge_reader.py", line 278, in MergeAttributeContainers
self._active_container_type, serialized_data)
File "plaso/plaso/storage/interface.py", line 600, in _DeserializeAttributeContainer
attribute_container = self._serializer.ReadSerialized(serialized_string)
File "plaso/plaso/serializer/json_serializer.py", line 404, in ReadSerialized
return cls.ReadSerializedDict(json_dict)
File "plaso/plaso/serializer/json_serializer.py", line 423, in ReadSerializedDict
json_object = cls._ConvertDictToObject(json_dict)
File "plaso/plaso/serializer/json_serializer.py", line 252, in _ConvertDictToObject
'supported.').format(attribute_name))
ValueError: Event data attribute value: return_value of type dict is not supported.

# Fixed code
def _ParseRecord(self, parser_mediator, file_object):
    """Parses an event record.

    Args:
      parser_mediator (ParserMediator): mediates interactions between parsers
          and other components, such as storage and dfvfs.
      file_object (dfvfs.FileIO): file-like object.

    Raises:
      ParseError: if the event record cannot be read.
    """
    header_record_offset = file_object.tell()

    # Check the header token type before reading the token data to prevent
    # variable size tokens to consume a large amount of memory.
    token_type = self._ParseTokenType(file_object, header_record_offset)
    if token_type not in self._HEADER_TOKEN_TYPES:
        raise errors.ParseError(
            "Unsupported header token type: 0x{0:02x}".format(token_type)
        )

    token_type, token_data = self._ParseToken(file_object, header_record_offset)

    if token_data.format_version != 11:
        raise errors.ParseError(
            "Unsupported format version type: {0:d}".format(token_data.format_version)
        )

    timestamp = token_data.microseconds + (
        token_data.timestamp * definitions.MICROSECONDS_PER_SECOND
    )

    event_type = token_data.event_type
    header_record_size = token_data.record_size
    record_end_offset = header_record_offset + header_record_size

    event_tokens = []
    return_token_values = None

    file_offset = file_object.tell()
    while file_offset < record_end_offset:
        token_type, token_data = self._ParseToken(file_object, file_offset)
        if not token_data:
            raise errors.ParseError(
                "Unsupported token type: 0x{0:02x}".format(token_type)
            )

        file_offset = file_object.tell()

        if token_type == self._TOKEN_TYPE_AUT_TRAILER:
            break

        token_type_string = self._TOKEN_TYPES.get(token_type, "UNKNOWN")
        token_values = self._FormatTokenData(token_type, token_data)
        event_tokens.append({token_type_string: token_values})

        if token_type in (self._TOKEN_TYPE_AUT_RETURN32, self._TOKEN_TYPE_AUT_RETURN64):
            # Make sure return_token_values is a string.
            return_token_values = (
                "{{'error': '{0:s}', 'token_status': {1:d}, 'call_status': {2:d}}}"
            ).format(
                token_values["error"],
                token_values["token_status"],
                token_values["call_status"],
            )

    if token_data.signature != self._TRAILER_TOKEN_SIGNATURE:
        raise errors.ParseError("Unsupported signature in trailer token.")

    if token_data.record_size != header_record_size:
        raise errors.ParseError(
            "Mismatch of event record size between header and trailer token."
        )

    event_data = BSMEventData()
    event_data.event_type = event_type
    event_data.extra_tokens = event_tokens
    event_data.offset = header_record_offset
    event_data.record_length = header_record_size
    event_data.return_value = return_token_values

    date_time = dfdatetime_posix_time.PosixTimeInMicroseconds(timestamp=timestamp)
    event = time_events.DateTimeValuesEvent(
        date_time, definitions.TIME_DESCRIPTION_CREATION
    )
    parser_mediator.ProduceEventWithEventData(event, event_data)