From 987fbc7ffba76551ab1599def928d9c1097f52f9 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:43:44 +0000 Subject: [PATCH 1/3] fix(client): preserve hardcoded query params when merging with user params --- src/lumaai/_base_client.py | 4 ++++ tests/test_client.py | 48 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/src/lumaai/_base_client.py b/src/lumaai/_base_client.py index 3a22f48..7e1e48f 100644 --- a/src/lumaai/_base_client.py +++ b/src/lumaai/_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 50e2121..c017405 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -432,6 +432,30 @@ def test_default_query_option(self) -> None: client.close() + def test_hardcoded_query_params_in_url(self, client: LumaAI) -> 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: LumaAI) -> None: request = client._build_request( FinalRequestOptions( @@ -1340,6 +1364,30 @@ async def test_default_query_option(self) -> None: await client.close() + async def test_hardcoded_query_params_in_url(self, async_client: AsyncLumaAI) -> 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: LumaAI) -> None: request = client._build_request( FinalRequestOptions( From a7c0bac3f06d2b362199676ea634ee07e4f33f47 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 11 Apr 2026 08:00:38 +0000 Subject: [PATCH 2/3] fix: ensure file data are only sent as 1 parameter --- src/lumaai/_utils/_utils.py | 5 +++-- tests/test_extract_files.py | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/lumaai/_utils/_utils.py b/src/lumaai/_utils/_utils.py index eec7f4a..63b8cd6 100644 --- a/src/lumaai/_utils/_utils.py +++ b/src/lumaai/_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 c6b23f1..4430299 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 c1c63c60cac21e7d1bb59a45d85902852f3dea4c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sat, 11 Apr 2026 08:00:57 +0000 Subject: [PATCH 3/3] release: 1.21.1 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 9 +++++++++ pyproject.toml | 2 +- src/lumaai/_version.py | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index ba231b0..9e1cded 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.21.0" + ".": "1.21.1" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d15854..3295300 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## 1.21.1 (2026-04-11) + +Full Changelog: [v1.21.0...v1.21.1](https://github.com/lumalabs/lumaai-python/compare/v1.21.0...v1.21.1) + +### Bug Fixes + +* **client:** preserve hardcoded query params when merging with user params ([987fbc7](https://github.com/lumalabs/lumaai-python/commit/987fbc7ffba76551ab1599def928d9c1097f52f9)) +* ensure file data are only sent as 1 parameter ([a7c0bac](https://github.com/lumalabs/lumaai-python/commit/a7c0bac3f06d2b362199676ea634ee07e4f33f47)) + ## 1.21.0 (2026-04-01) Full Changelog: [v1.20.1...v1.21.0](https://github.com/lumalabs/lumaai-python/compare/v1.20.1...v1.21.0) diff --git a/pyproject.toml b/pyproject.toml index 5f62384..e928edd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "lumaai" -version = "1.21.0" +version = "1.21.1" description = "The official Python library for the lumaai API" dynamic = ["readme"] license = "Apache-2.0" diff --git a/src/lumaai/_version.py b/src/lumaai/_version.py index cf210dc..8b5372a 100644 --- a/src/lumaai/_version.py +++ b/src/lumaai/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "lumaai" -__version__ = "1.21.0" # x-release-please-version +__version__ = "1.21.1" # x-release-please-version