From 4e3c1272bc9875acf397873b9f8aacd579c17152 Mon Sep 17 00:00:00 2001 From: Fred <323546+fguillot@users.noreply.github.com> Date: Mon, 23 Mar 2026 20:47:18 -0700 Subject: [PATCH] fix(client): preserve falsy query param values in _get_params Use `if v is not None` instead of `if v` so that valid falsy values like 0, False, and "" are not silently dropped from query parameters. --- miniflux.py | 2 +- tests/test_client.py | 24 +++++++++++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/miniflux.py b/miniflux.py index a664797..f268d41 100644 --- a/miniflux.py +++ b/miniflux.py @@ -159,7 +159,7 @@ def _get_endpoint(self, path: str) -> str: return f"{self._base_url}/v{self.API_VERSION}{path}" def _get_params(self, **kwargs) -> Optional[dict]: - params = {k: v for k, v in kwargs.items() if v} + params = {k: v for k, v in kwargs.items() if v is not None} return params if len(params) > 0 else None def _get_modification_params(self, **kwargs) -> dict: diff --git a/tests/test_client.py b/tests/test_client.py index 3a7c212..47e0a26 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -999,7 +999,29 @@ def test_get_entries_with_starred_param_at_false(self): session.get.assert_called_once_with( "http://localhost/v1/entries", - params={"after_entry_id": 123}, + params={"starred": False, "after_entry_id": 123}, + timeout=30, + ) + + assert result == expected_result + + def test_get_entries_with_zero_offset(self): + session = requests.Session() + expected_result = [] + + response = mock.Mock() + response.status_code = 200 + response.json.return_value = expected_result + + session.get = mock.Mock() + session.get.return_value = response + + client = miniflux.Client("http://localhost", "username", "password", session=session) + result = client.get_entries(offset=0, status="unread") + + session.get.assert_called_once_with( + "http://localhost/v1/entries", + params={"offset": 0, "status": "unread"}, timeout=30, )