Skip to content

Commit 93feb49

Browse files
vdusekclaude
andcommitted
fix: Only include actorStandby when at least one field is provided
Update the `get_actor_representation` function to conditionally include the `actorStandby` object only when at least one of its fields is not None. This prevents sending empty or null-only actorStandby objects to the API. According to the API changes, actorStandby is optional and should only be included when needed, with isEnabled being the only required field within the object when present. Related JS client issue: apify/apify-client-js#832 Closes #595 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent e0dad8b commit 93feb49

File tree

1 file changed

+20
-6
lines changed
  • src/apify_client/clients/resource_clients

1 file changed

+20
-6
lines changed

src/apify_client/clients/resource_clients/actor.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def get_actor_representation(
6262
actor_permission_level: ActorPermissionLevel | None = None,
6363
) -> dict:
6464
"""Get dictionary representation of the Actor."""
65-
return {
65+
actor_dict = {
6666
'name': name,
6767
'title': title,
6868
'description': description,
@@ -85,17 +85,31 @@ def get_actor_representation(
8585
'body': example_run_input_body,
8686
'contentType': example_run_input_content_type,
8787
},
88-
'actorStandby': {
88+
'pricingInfos': pricing_infos,
89+
'actorPermissionLevel': actor_permission_level,
90+
}
91+
92+
# Only include actorStandby if at least one field is provided
93+
if any(
94+
[
95+
actor_standby_is_enabled is not None,
96+
actor_standby_desired_requests_per_actor_run is not None,
97+
actor_standby_max_requests_per_actor_run is not None,
98+
actor_standby_idle_timeout_secs is not None,
99+
actor_standby_build is not None,
100+
actor_standby_memory_mbytes is not None,
101+
]
102+
):
103+
actor_dict['actorStandby'] = {
89104
'isEnabled': actor_standby_is_enabled,
90105
'desiredRequestsPerActorRun': actor_standby_desired_requests_per_actor_run,
91106
'maxRequestsPerActorRun': actor_standby_max_requests_per_actor_run,
92107
'idleTimeoutSecs': actor_standby_idle_timeout_secs,
93108
'build': actor_standby_build,
94109
'memoryMbytes': actor_standby_memory_mbytes,
95-
},
96-
'pricingInfos': pricing_infos,
97-
'actorPermissionLevel': actor_permission_level,
98-
}
110+
}
111+
112+
return actor_dict
99113

100114

101115
class ActorClient(ResourceClient):

0 commit comments

Comments
 (0)