From a5e3964c45b13447d953a4372214914629b4c3f1 Mon Sep 17 00:00:00 2001 From: Vlada Dusek Date: Tue, 17 Feb 2026 14:54:06 +0100 Subject: [PATCH] fix: use 'is not None' checks for json parameter to preserve falsy values Truthiness checks (if json) silently dropped valid falsy JSON payloads like 0, "", [], {}, and False. For example, posting json=[] would not serialize or send the empty list. Changed to explicit None checks. Co-Authored-By: Claude Opus 4.6 --- src/apify_client/_http_client.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/apify_client/_http_client.py b/src/apify_client/_http_client.py index 131d32f3..2d76e4b5 100644 --- a/src/apify_client/_http_client.py +++ b/src/apify_client/_http_client.py @@ -101,14 +101,14 @@ def _prepare_request_call( data: Any = None, json: JSONSerializable | None = None, ) -> tuple[dict, dict | None, Any]: - if json and data: + if json is not None and data is not None: raise ValueError('Cannot pass both "json" and "data" parameters at the same time!') if not headers: headers = {} # dump JSON data to string, so they can be gzipped - if json: + if json is not None: data = jsonlib.dumps(json, ensure_ascii=False, allow_nan=False, default=str).encode('utf-8') headers['Content-Type'] = 'application/json'