snipsco/hermes-protocol

[Python] Exception when txt="" in publish_continue_session()

cpoisson opened this issue · 0 comments

Version
0.4.1

Description
An exception occurs when providing an empty string to the tts parameters in "publish_continue_session"

Logs

2019-04-29 11:57:26,862 - INFO : SnipsPlatform.terminate - Snips Platform terminated
FAILED

============================================================================================================== FAILURES ===============================================================================================================
__________________________________________________________________________________________ TestContinueSession.test_publish_continue_session __________________________________________________________________________________________

self = <test_dialogue.TestContinueSession object at 0x10fea47b8>

    def test_publish_continue_session(self):
        """
        Given:
            - An assistant containing the weather application is installed.
            - The user utter "Hey Snips! What is the weather in Tokyo"
            - The assistant catch the intent and continue the session and utter some feedback.
    
        When:
            - The user utter "What is the weather in San Francisco?"
    
        Then:
            - The SearchWeatherForecast intent MUST be published.
            - The forecast_locality slot MUST contain the value San Francisco
            - The session is closed after publishing an end session using Hermes.
        """
    
        # Given
        with WeatherDemoAssistant() as weather_assistant:
    
            params = {
                "hijack": True,
                "no_mike": True,
                "sound_feedback_disabled_default": True,
                "assistant": weather_assistant.assistant_path
            }
    
            with SnipsPlatform(**params) as snips:
    
                intent_name = "searchWeatherForecast"
    
                with IntentListener(intent_name) as intent_listener:
                    snips.audio_server.inject_audio(get_asset("hey_snips-whats_the_weather_in_tokyo.wav"))
    
                    assert intent_listener.exists()
    
                    client: Hermes = intent_listener.queue[0].client
                    msg: IntentMessage = intent_listener.queue[0].message
    
>                   client.publish_continue_session(msg.session_id, "", [intent_name])

client     = <hermes_python.hermes.Hermes object at 0x10ff26320>
intent_listener = <snipsbox.hermes.IntentListener object at 0x10ff262b0>
intent_name = 'searchWeatherForecast'
msg        = <hermes_python.ontology.dialogue.intent.IntentMessage object at 0x10ff26978>
params     = {'assistant': '/var/folders/1g/0sv9v9pn5mb3q1n6szct90t00000gn/T/proj_WEATHER-DEMO-EN/assistant',
 'hijack': True,
 'no_mike': True,
 'sound_feedback_disabled_default': True}
self       = <test_dialogue.TestContinueSession object at 0x10fea47b8>
snips      = <snipsbox.services.SnipsPlatform object at 0x10fea4588>
weather_assistant = <snipsbox.assistant.WeatherDemoAssistant object at 0x10fb741d0>

tests/platform/test_dialogue.py:178: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../../.virtualenvs/snips-tests/lib/python3.7/site-packages/hermes_python/hermes.py:188: in publish_continue_session
    self.ffi.dialogue.publish_continue_session(continue_session_msg)
../../.virtualenvs/snips-tests/lib/python3.7/site-packages/hermes_python/api/ffi/dialogue.py:135: in publish_continue_session
    message
../../.virtualenvs/snips-tests/lib/python3.7/site-packages/hermes_python/api/ffi/dialogue.py:192: in _call_foreign_function
    ptr_to_foreign_function_argument
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

args = (<hermes_python.api.ffi.dialogue.LP_CDialogueFacade object at 0x10e397bf8>, <cparam 'P' (0x10ff1c510)>), kwargs = {}, return_code = 1, empty_string = b''
error_p = <hermes_python.ffi.ontology.LP_c_char_p object at 0x10fec4598>, error_cause = 'could not borrow, unexpected null pointer\n'

    def wrapped_library_call(*args, **kwargs):
        return_code = lib_func(*args, **kwargs)
        if return_code > 0:  # An error occured
            empty_string = "".encode('utf-8')
            error_p = POINTER(c_char_p)(c_char_p(empty_string))
            # Retrieve the last error and put it in the memory location error_p points to
            lib.hermes_get_last_error(error_p)
            error_cause = string_at(error_p.contents).decode('utf-8')
>           raise LibException(error_cause)
E           hermes_python.ffi.LibException: could not borrow, unexpected null pointer

args       = (<hermes_python.api.ffi.dialogue.LP_CDialogueFacade object at 0x10e397bf8>,
 <cparam 'P' (0x10ff1c510)>)
empty_string = b''
error_cause = 'could not borrow, unexpected null pointer\n'
error_p    = <hermes_python.ffi.ontology.LP_c_char_p object at 0x10fec4598>
kwargs     = {}
lib_func   = <_FuncPtr object at 0x10fb54048>
return_code = 1