@@ -35,15 +35,32 @@ def _transform_to_list(value: Any) -> list[str] | None:
3535
3636
3737class ActorStorages (TypedDict ):
38+ """Mapping of storage aliases to their IDs, grouped by storage type.
39+
40+ Populated from the `ACTOR_STORAGES_JSON` env var that the Apify platform sets when an Actor declares
41+ named storages in its `actor.json` schema. Each key maps a user-defined alias (e.g. `'custom'`)
42+ to the platform-assigned storage ID.
43+ """
44+
3845 key_value_stores : dict [str , str ]
3946 datasets : dict [str , str ]
4047 request_queues : dict [str , str ]
4148
4249
43- def _load_storage_keys (
44- data : None | str | ActorStorages ,
45- ) -> ActorStorages | None :
46- """Load storage keys."""
50+ def _load_storage_keys (data : None | str | ActorStorages ) -> ActorStorages | None :
51+ """Parse the `ACTOR_STORAGES_JSON` value into a normalized `ActorStorages` dict.
52+
53+ The platform provides this as a JSON string with camelCase keys (`keyValueStores`, `requestQueues`, `datasets`).
54+ This validator deserializes the JSON when needed and normalizes the keys to snake_case, falling back to empty
55+ dicts for missing storage types.
56+
57+ Args:
58+ data: Raw value - `None` when the env var is unset, a JSON string from the env var, or an already-parsed
59+ `ActorStorages` dict when set programmatically.
60+
61+ Returns:
62+ Normalized storage mapping, or `None` if the input is `None`.
63+ """
4764 if data is None :
4865 return None
4966 storage_mapping = json .loads (data ) if isinstance (data , str ) else data
@@ -470,7 +487,7 @@ class Configuration(CrawleeConfiguration):
470487 ActorStorages | None ,
471488 Field (
472489 alias = 'actor_storages_json' ,
473- description = 'Storage IDs for the actor ' ,
490+ description = 'Mapping of storage aliases to their platform-assigned IDs. ' ,
474491 ),
475492 BeforeValidator (_load_storage_keys ),
476493 ] = None
0 commit comments