From c77381dcb278b42397c07d64a98da3115e3a9cc4 Mon Sep 17 00:00:00 2001 From: Bert Verstraete Date: Fri, 1 Nov 2024 15:33:52 +0100 Subject: [PATCH] [Data Workflows] More robust path parameter encoding (#2004) --- CHANGELOG.md | 5 ++++- cognite/client/_api/workflows.py | 9 +++++---- cognite/client/_version.py | 2 +- pyproject.toml | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e7b216fe97..5d2b6c39a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,11 +17,14 @@ Changes are grouped as follows - `Fixed` for any bug fixes. - `Security` in case of vulnerabilities. +## [7.64.4] - 2024-11-01 +### Fixed +- Data Workflows: apply more robust path parameter encoding. + ## [7.64.3] - 2024-11-01 ### Fixed - Removed superfluous properties from authentication subclass read objects - ## [7.64.2] - 2024-10-31 ### Fixed - `HostedExtractor` REST source `authentication` property updated to follow API change. diff --git a/cognite/client/_api/workflows.py b/cognite/client/_api/workflows.py index 6508ea2528..4f53ffde23 100644 --- a/cognite/client/_api/workflows.py +++ b/cognite/client/_api/workflows.py @@ -3,7 +3,6 @@ import warnings from collections.abc import Iterator, MutableSequence from typing import TYPE_CHECKING, Any, Literal, TypeAlias, overload -from urllib.parse import quote from cognite.client._api_client import APIClient from cognite.client._constants import DEFAULT_LIMIT_READ @@ -29,6 +28,7 @@ WorkflowVersionUpsert, ) from cognite.client.exceptions import CogniteAPIError +from cognite.client.utils._auxiliary import interpolate_and_url_encode from cognite.client.utils._identifier import ( IdentifierSequence, WorkflowVersionIdentifierSequence, @@ -397,7 +397,8 @@ def run( body["metadata"] = metadata response = self._post( - url_path=f"/workflows/{quote(workflow_external_id, '')}/versions/{quote(version, '')}/run", json=body + url_path=interpolate_and_url_encode("/workflows/{}/versions/{}/run", workflow_external_id, version), + json=body, ) return WorkflowExecution._load(response.json()) @@ -678,7 +679,7 @@ def retrieve(self, workflow_external_id: str, version: str) -> WorkflowVersion | """ try: response = self._get( - url_path=f"/workflows/{quote(workflow_external_id, '')}/versions/{quote(version, '')}", + url_path=interpolate_and_url_encode("/workflows/{}/versions/{}", workflow_external_id, version) ) except CogniteAPIError as e: if e.code == 404: @@ -823,7 +824,7 @@ def retrieve(self, external_id: str) -> Workflow | None: >>> res = client.workflows.retrieve("my workflow") """ try: - response = self._get(url_path=f"{self._RESOURCE_PATH}/{quote(external_id, '')}") + response = self._get(url_path=interpolate_and_url_encode("/workflows/{}", external_id)) except CogniteAPIError as e: if e.code == 404: return None diff --git a/cognite/client/_version.py b/cognite/client/_version.py index 90d93e63ff..d6047efe90 100644 --- a/cognite/client/_version.py +++ b/cognite/client/_version.py @@ -1,4 +1,4 @@ from __future__ import annotations -__version__ = "7.64.3" +__version__ = "7.64.4" __api_subversion__ = "20230101" diff --git a/pyproject.toml b/pyproject.toml index ea136400c5..07a58aa2de 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [tool.poetry] name = "cognite-sdk" -version = "7.64.3" +version = "7.64.4" description = "Cognite Python SDK" readme = "README.md" documentation = "https://cognite-sdk-python.readthedocs-hosted.com"