Issue
When utilizing the Python SDK to interact with a Control Hub cluster in order to create/modify pipelines, the following error is encountered while trying to instantiate a PipelineBuilder object:
>>> from streamsets.sdk.sch import ControlHub
>>> sch = ControlHub('https://cloud.streamsets.com', username="xxx", password="xxx")
>>> sch_pipeline_builder = sch.get_pipeline_builder()
Encountered an error while doing POST on https://cloud.streamsets.com/pipelinestore/rest/v1/pipelines/exportPipelineCommits. Response: {'_content': b'{"ISSUES":[{"code":"PIPELINE_STORE_18","message":"Failed to export pipeline a5a48aaa-ea59-40da-8c31-1303139f3193:dpmsupport.dp, error is null"}]}', '_content_consumed': True, '_next': None, 'status_code': 400, 'headers': {'Date': 'Tue, 21 Apr 2020 19:04:49 GMT', 'Content-Type': 'application/json', 'Content-Length': '145', 'Strict-Transport-Security': 'max-age=15768000', 'X-XSS-Protection': '1;mode=block', 'X-Content-Type-Options': 'nosniff', 'X-Frame-Options': 'SAMEORIGIN', 'Content-Security-Policy': "frame-ancestors 'self';"}, 'raw': <urllib3.response.HTTPResponse object at 0x10dd7acf8>, 'url': 'https://cloud.streamsets.com/pipelinestore/rest/v1/pipelines/exportPipelineCommits', 'encoding': None, 'history': [], 'reason': 'Bad Request', 'cookies': <RequestsCookieJar[]>, 'elapsed': datetime.timedelta(0, 0, 398965), 'request': <PreparedRequest [POST]>, 'connection': <requests.adapters.HTTPAdapter object at 0x10ce12cc0>}
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/xxx/.pyenv/versions/3.6.8/lib/python3.6/site-packages/streamsets/sdk/sch.py", line 184, in get_pipeline_builder
pipelines_zip_data = self.api_client.export_pipelines(body=[commit_id]).response.content
File "streamsets/sdk/sch_api.pyx", line 763, in sdk.sch_api.ApiClient.export_pipelines
File "streamsets/sdk/sch_api.pyx", line 2394, in sdk.sch_api.ApiClient._post
File "streamsets/sdk/sch_api.pyx", line 2417, in sdk.sch_api.ApiClient._handle_http_error
File "streamsets/sdk/sch_api.pyx", line 2411, in sdk.sch_api.ApiClient._handle_http_error
File "/Users/xxx/.pyenv/versions/3.6.8/lib/python3.6/site-packages/requests/models.py", line 940, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://cloud.streamsets.com/pipelinestore/rest/v1/pipelines/exportPipelineCommits
Criteria:
1. Running with a version of the Python SDK that is 3.7.0 or earlier
2. Control Hub version is 3.15.0 or later
Solution:
As a result of a change required for Control Hub's 'export pipeline' functionality in 3.15.0, the SDK is unable to successfully interact with the 'exportPipelineCommits' endpoint.
In order to resolve the issue, the Python SDK needs to be upgraded to version 3.7.1 or later.