Skip to content

Commit 9dc10d4

Browse files
committed
fix: Handle truncated unique_key in list_head by fetching full request data
Closes: #627
1 parent af01e50 commit 9dc10d4

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/apify/storage_clients/_apify/_request_queue_single_client.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,14 @@ async def _list_head(self) -> None:
236236

237237
# Update the cached data
238238
for request_data in response.get('items', []):
239+
# Due to https://github.com/apify/apify-core/blob/v0.1377.0/src/api/src/lib/request_queues/request_queue.ts#L53,
240+
# the list_head endpoint may return truncated fields for long requests (e.g., long URLs or unique keys).
241+
# If truncation is detected, fetch the full request data by its ID from the API.
242+
# This is a temporary workaround - the caching will be refactored to use request IDs instead of unique keys.
243+
# See https://github.com/apify/apify-sdk-python/issues/630 for details.
244+
if '[truncated]' in request_data['uniqueKey'] or '[truncated]' in request_data['url']:
245+
request_data = await self._api_client.get_request(request_id=request_data['id']) # noqa: PLW2901
246+
239247
request = Request.model_validate(request_data)
240248

241249
if request.unique_key in self._requests_in_progress:

0 commit comments

Comments
 (0)