Skip to content

Commit 7112c09

Browse files
vdusekclaude
andauthored
fix: Only include Actor standby when at least one field is provided (#597)
Update the `get_actor_representation` function to conditionally include the `actor_standby` object only when at least one of its fields is not None. This prevents sending empty or null-only actor_standby objects to the API. **Background:** According to the API changes, `actor_standby` is optional and should only be included when needed. When present, `is_enabled` is the only required field within the object. **Changes:** - Modified `get_actor_representation()` to conditionally add `actor_standby` to the Actor dictionary - The object is only included if at least one of the following fields is not None: - `actor_standby_is_enabled` - `actor_standby_desired_requests_per_actor_run` - `actor_standby_max_requests_per_actor_run` - `actor_standby_idle_timeout_secs` - `actor_standby_build` - `actor_standby_memory_mbytes` **Related:** - 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 7112c09

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)