Skip to content

Commit 4732185

Browse files
committed
fix: ensure explicit empty input is correctly passed to Apify actor
1 parent 30412f7 commit 4732185

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

src/strands_tools/apify.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ def run_actor(
200200
self._validate_positive(memory_mbytes, "memory_mbytes")
201201

202202
call_kwargs: Dict[str, Any] = {
203-
"run_input": run_input or {},
203+
"run_input": run_input if run_input is not None else {},
204204
"timeout_secs": timeout_secs,
205205
"logger": None, # Suppress verbose apify-client logging not useful to end users
206206
}

tests/test_apify.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,17 @@ def test_run_actor_default_input(mock_apify_env, mock_apify_client):
150150
assert call_kwargs["run_input"] == {}
151151

152152

153+
def test_run_actor_explicit_empty_input(mock_apify_env, mock_apify_client):
154+
"""Actor run passes through an explicitly empty dict instead of treating it as falsy."""
155+
empty_input: dict = {}
156+
with patch("strands_tools.apify.ApifyClient", return_value=mock_apify_client):
157+
result = apify_run_actor(actor_id="actor/my-scraper", run_input=empty_input)
158+
159+
assert result["status"] == "success"
160+
call_kwargs = mock_apify_client.actor.return_value.call.call_args.kwargs
161+
assert call_kwargs["run_input"] is empty_input
162+
163+
153164
def test_run_actor_with_memory(mock_apify_env, mock_apify_client):
154165
"""Actor run passes memory_mbytes when provided."""
155166
with patch("strands_tools.apify.ApifyClient", return_value=mock_apify_client):

0 commit comments

Comments
 (0)