finos / symphony-bdk-python

Symphony Python Bot Development Kit (BDK)
https://symphony-bdk-python.finos.org/
Apache License 2.0
31 stars 34 forks source link

truststorePath raise a key error #41

Closed HaoYang0000 closed 5 years ago

HaoYang0000 commented 5 years ago

When upgrading the version from 0.1.11 to 0.1.15, I did the following:

  1. Reimport the classes(From camel case to snake case)
  2. Update the implementation of IMListener abstract method(From camel case to snake case).
  3. Consider attribute "truststore" is optional in config.json, I didn't put that in config.json. But I got an error like the following img: image

I also tried:

  1. Adding "truststore" to config.json, same error.
  2. Adding "truststorePath" with value empty string "", it gives me an error on the response: image

To solve the issue:

  1. We can either update the "symphony-api-client-python/sym_api_client_python/configure/configure.py", adding "truststore" into self.data.
  2. Or, we can consider using "if self.config.data.get('truststorePath')" instead of "self.config.data['truststorePath']" in "symphony-api-client-python/sym_api_client_python/clients/sym_bot_client.py".
karlmoll commented 5 years ago

what error are you getting from the datafeed? create_datafeed() doesn't return the response, it returns response[id]. The following call works successfully for the call:

In [7]: event_service.create_datafeed().format(id.__str__)
Out[7]: 'fb7beb76-d478-41d7-9541-57a1052b90ec'

The above code was generated with the truststorePath: "". I agree that this is not ideal, but it is not a blocker. I will update the README to indicate that this is a required field but can be empty, and we will include a rewritten configure.py that will better handle this in the next major release.

HaoYang0000 commented 5 years ago

Thanks for the response and update to the Readme. The above exception I believe is thrown by SymBotClient in execute_rest_call method, line 147 super().handle_error(response, self). I received a 400 from the response when trying to create a new datafeed. The filtered(the url are replaced with xxxxxs) exception is the following:

sym_api_client_python.exceptions.APIClientErrorException.APIClientErrorException: Client Error Occurred: {'_content': b'', '_content_consumed': True, '_next': None, 'status_code': 400, 'headers': {'Access-Control-Allow-Credentials': 'true', 'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS, HEAD', 'Date': 'Wed, 07 Aug 2019 15:53:07 GMT', 'P3P': 'CP="Symphony does not have a P3P policy"', 'Server': 'nginx', 'X-Application-Context': 'application:cloud:9443', 'X-Content-Type-Options': 'nosniff', 'X-Trace-Id': 'NV7hxA', 'X-XSS-Protection': '1; mode=block', 'Content-Length': '0', 'Connection': 'keep-alive'}, 'raw': <urllib3.response.HTTPResponse object at 0x7fb68cf48320>, 'url': 'https://xxxxxxxxxxxxxxxxxxxx:443/agent/v4/datafeed/create', 'encoding': None, 'history': [], 'reason': '', 'cookies': <RequestsCookieJar[]>, 'elapsed': datetime.timedelta(microseconds=149560), 'request': <PreparedRequest [POST]>, 'connection': <requests.adapters.HTTPAdapter object at 0x7fb68cf482b0>} Notice that on version 0.1.11 it works fine when create datafeed, but on 0.1.17 it keeps throwning the 400 error. Any idea what could trigger that? Appreciate it.

HaoYang0000 commented 5 years ago

I dig a little deep, and looks like the issue was on the auth process, we tried to fetch the session_token. But when switch release version, from camalCase to snake_case we didn't update that. Thanks for the help and close the issue.