From fa95230da42fb276e074db0d8f882d59172f867c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 8 Apr 2026 04:13:21 +0000 Subject: [PATCH 1/3] fix(client): preserve hardcoded query params when merging with user params --- src/onebusaway/_base_client.py | 4 +++ tests/test_client.py | 48 ++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/src/onebusaway/_base_client.py b/src/onebusaway/_base_client.py index 1990426..79c01ac 100644 --- a/src/onebusaway/_base_client.py +++ b/src/onebusaway/_base_client.py @@ -540,6 +540,10 @@ def _build_request( files = cast(HttpxRequestFiles, ForceMultipartDict()) prepared_url = self._prepare_url(options.url) + # preserve hard-coded query params from the url + if params and prepared_url.query: + params = {**dict(prepared_url.params.items()), **params} + prepared_url = prepared_url.copy_with(raw_path=prepared_url.raw_path.split(b"?", 1)[0]) if "_" in prepared_url.host: # work around https://github.com/encode/httpx/discussions/2880 kwargs["extensions"] = {"sni_hostname": prepared_url.host.replace("_", "-")} diff --git a/tests/test_client.py b/tests/test_client.py index 0940f79..dfc9d0f 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -420,6 +420,30 @@ def test_default_query_option(self) -> None: client.close() + def test_hardcoded_query_params_in_url(self, client: OnebusawaySDK) -> None: + request = client._build_request(FinalRequestOptions(method="get", url="/foo?beta=true")) + url = httpx.URL(request.url) + assert dict(url.params) == {"beta": "true"} + + request = client._build_request( + FinalRequestOptions( + method="get", + url="/foo?beta=true", + params={"limit": "10", "page": "abc"}, + ) + ) + url = httpx.URL(request.url) + assert dict(url.params) == {"beta": "true", "limit": "10", "page": "abc"} + + request = client._build_request( + FinalRequestOptions( + method="get", + url="/files/a%2Fb?beta=true", + params={"limit": "10"}, + ) + ) + assert request.url.raw_path == b"/files/a%2Fb?beta=true&limit=10" + def test_request_extra_json(self, client: OnebusawaySDK) -> None: request = client._build_request( FinalRequestOptions( @@ -1314,6 +1338,30 @@ async def test_default_query_option(self) -> None: url = httpx.URL(request.url) assert dict(url.params) == {"foo": "baz", "query_param": "overridden", "key": api_key} + async def test_hardcoded_query_params_in_url(self, async_client: AsyncOnebusawaySDK) -> None: + request = async_client._build_request(FinalRequestOptions(method="get", url="/foo?beta=true")) + url = httpx.URL(request.url) + assert dict(url.params) == {"beta": "true"} + + request = async_client._build_request( + FinalRequestOptions( + method="get", + url="/foo?beta=true", + params={"limit": "10", "page": "abc"}, + ) + ) + url = httpx.URL(request.url) + assert dict(url.params) == {"beta": "true", "limit": "10", "page": "abc"} + + request = async_client._build_request( + FinalRequestOptions( + method="get", + url="/files/a%2Fb?beta=true", + params={"limit": "10"}, + ) + ) + assert request.url.raw_path == b"/files/a%2Fb?beta=true&limit=10" + def test_request_extra_json(self, client: OnebusawaySDK) -> None: request = client._build_request( FinalRequestOptions( From abc0ea7e46034c4d823f523cca5f2158b51a4133 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 11 Apr 2026 06:54:48 +0000 Subject: [PATCH 2/3] fix: ensure file data are only sent as 1 parameter --- src/onebusaway/_utils/_utils.py | 5 +++-- tests/test_extract_files.py | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/onebusaway/_utils/_utils.py b/src/onebusaway/_utils/_utils.py index eec7f4a..63b8cd6 100644 --- a/src/onebusaway/_utils/_utils.py +++ b/src/onebusaway/_utils/_utils.py @@ -86,8 +86,9 @@ def _extract_items( index += 1 if is_dict(obj): try: - # We are at the last entry in the path so we must remove the field - if (len(path)) == index: + # Remove the field if there are no more dict keys in the path, + # only "" traversal markers or end. + if all(p == "" for p in path[index:]): item = obj.pop(key) else: item = obj[key] diff --git a/tests/test_extract_files.py b/tests/test_extract_files.py index 8b35513..7557c18 100644 --- a/tests/test_extract_files.py +++ b/tests/test_extract_files.py @@ -35,6 +35,15 @@ def test_multiple_files() -> None: assert query == {"documents": [{}, {}]} +def test_top_level_file_array() -> None: + query = {"files": [b"file one", b"file two"], "title": "hello"} + assert extract_files(query, paths=[["files", ""]]) == [ + ("files[]", b"file one"), + ("files[]", b"file two"), + ] + assert query == {"title": "hello"} + + @pytest.mark.parametrize( "query,paths,expected", [ From 6f1e2d4673e62314780e465aed86a840a2a3c41a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 11 Apr 2026 06:55:08 +0000 Subject: [PATCH 3/3] release: 1.24.2 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 9 +++++++++ pyproject.toml | 2 +- src/onebusaway/_version.py | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 347a18e..800156f 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.24.1" + ".": "1.24.2" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a341e6..571a51a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## 1.24.2 (2026-04-11) + +Full Changelog: [v1.24.1...v1.24.2](https://github.com/OneBusAway/python-sdk/compare/v1.24.1...v1.24.2) + +### Bug Fixes + +* **client:** preserve hardcoded query params when merging with user params ([fa95230](https://github.com/OneBusAway/python-sdk/commit/fa95230da42fb276e074db0d8f882d59172f867c)) +* ensure file data are only sent as 1 parameter ([abc0ea7](https://github.com/OneBusAway/python-sdk/commit/abc0ea7e46034c4d823f523cca5f2158b51a4133)) + ## 1.24.1 (2026-04-01) Full Changelog: [v1.24.0...v1.24.1](https://github.com/OneBusAway/python-sdk/compare/v1.24.0...v1.24.1) diff --git a/pyproject.toml b/pyproject.toml index 7076507..2d97626 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "onebusaway" -version = "1.24.1" +version = "1.24.2" description = "The official Python library for the onebusaway-sdk API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/onebusaway/_version.py b/src/onebusaway/_version.py index f7b3f58..64a489f 100644 --- a/src/onebusaway/_version.py +++ b/src/onebusaway/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "onebusaway" -__version__ = "1.24.1" # x-release-please-version +__version__ = "1.24.2" # x-release-please-version