From 2ce53f2e93143e3073a5b565a5a2e7b6ae16a894 Mon Sep 17 00:00:00 2001 From: Rian Stockbower Date: Thu, 4 Jun 2026 11:05:09 -0400 Subject: [PATCH 1/2] fix(chocolatey): encode moderation OData spaces Closes #33 --- actions/chocolatey-push/chocolatey_push.py | 5 ++++- actions/chocolatey-push/test_chocolatey_push.py | 10 ++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/actions/chocolatey-push/chocolatey_push.py b/actions/chocolatey-push/chocolatey_push.py index 7864e95..e43e450 100644 --- a/actions/chocolatey-push/chocolatey_push.py +++ b/actions/chocolatey-push/chocolatey_push.py @@ -133,7 +133,10 @@ def probe_package_state(package_id: str, http_get=None) -> PackageState: if package_response.status != 200: raise ProbeError(f"Chocolatey package endpoint returned HTTP {package_response.status}") - query = urlencode({"$filter": f"Id eq '{_odata_string(package_id)}'", "$orderby": "Version desc"}) + query = urlencode( + {"$filter": f"Id eq '{_odata_string(package_id)}'", "$orderby": "Version desc"}, + quote_via=quote, + ) feed_response = http_get(f"{COMMUNITY_API}/Packages()?{query}") if feed_response.status != 200: raise ProbeError(f"Chocolatey package listing returned HTTP {feed_response.status}") diff --git a/actions/chocolatey-push/test_chocolatey_push.py b/actions/chocolatey-push/test_chocolatey_push.py index b5b766f..eefeaf2 100644 --- a/actions/chocolatey-push/test_chocolatey_push.py +++ b/actions/chocolatey-push/test_chocolatey_push.py @@ -226,7 +226,10 @@ def http_get(url): assert state.pending_first_submission is True assert seen[0] == "https://community.chocolatey.org/api/v2/package/codereview-cli" - assert "%24filter=Id+eq+%27codereview-cli%27" in seen[1] + assert seen[1] == ( + "https://community.chocolatey.org/api/v2/Packages()?" + "%24filter=Id%20eq%20%27codereview-cli%27&%24orderby=Version%20desc" + ) def test_probe_package_state_escapes_odata_string_quotes(): @@ -241,7 +244,10 @@ def http_get(url): state = chocolatey_push.probe_package_state("code'review-cli", http_get=http_get) assert state.pending_first_submission is True - assert "%24filter=Id+eq+%27code%27%27review-cli%27" in seen[1] + assert seen[1] == ( + "https://community.chocolatey.org/api/v2/Packages()?" + "%24filter=Id%20eq%20%27code%27%27review-cli%27&%24orderby=Version%20desc" + ) def test_request_text_transport_failure_fails_closed(monkeypatch): From b94a77e80df3d9ddb444ef081010b32647c8744d Mon Sep 17 00:00:00 2001 From: Rian Stockbower Date: Thu, 4 Jun 2026 11:08:02 -0400 Subject: [PATCH 2/2] test(chocolatey): cover retry probe URL --- actions/chocolatey-push/test_chocolatey_push.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/actions/chocolatey-push/test_chocolatey_push.py b/actions/chocolatey-push/test_chocolatey_push.py index eefeaf2..4db9d7b 100644 --- a/actions/chocolatey-push/test_chocolatey_push.py +++ b/actions/chocolatey-push/test_chocolatey_push.py @@ -102,13 +102,19 @@ def test_forbidden_pending_first_submission_succeeds_with_warning(tmp_path): work = _working_dir(tmp_path) choco_dir = work / "packaging" / "chocolatey" calls = [] + seen_urls = [] + http_get = _http_get({"/package/codereview-cli": (200, "nupkg"), "/Packages()?": (200, EMPTY_FEED)}) + + def recording_http_get(url): + seen_urls.append(url) + return http_get(url) rc = chocolatey_push.pack_and_push( package_id="codereview-cli", working_dir=work, api_key="key", command_runner=_forbidden_push_runner(tmp_path, calls=calls), - http_get=_http_get({"/package/codereview-cli": (200, "nupkg"), "/Packages()?": (200, EMPTY_FEED)}), + http_get=recording_http_get, summary_path=str(summary), ) @@ -128,6 +134,13 @@ def test_forbidden_pending_first_submission_succeeds_with_warning(tmp_path): choco_dir, ), ] + assert seen_urls == [ + "https://community.chocolatey.org/api/v2/package/codereview-cli", + ( + "https://community.chocolatey.org/api/v2/Packages()?" + "%24filter=Id%20eq%20%27codereview-cli%27&%24orderby=Version%20desc" + ), + ] assert "was not accepted for this release" in summary.read_text()