From 1b85a7b009e7fb6feb4dd6caea99468cbe794880 Mon Sep 17 00:00:00 2001 From: Vlada Dusek Date: Wed, 15 Apr 2026 14:42:30 +0200 Subject: [PATCH 1/2] fix: increase random suffix length in integration test resource names The schedule integration test was flaky due to name collisions with stale resources left over from previous CI runs that were cancelled before cleanup. Increasing the random suffix from 5 to 16 characters makes such collisions virtually impossible. Co-Authored-By: Claude Opus 4.6 (1M context) --- tests/integration/_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/_utils.py b/tests/integration/_utils.py index a2fb4197..14a62e8d 100644 --- a/tests/integration/_utils.py +++ b/tests/integration/_utils.py @@ -66,7 +66,7 @@ def get_random_string(length: int = 10) -> str: def get_random_resource_name(resource: str) -> str: """Generate a random resource name for test resources.""" - return f'python-client-test-{resource}-{get_random_string(5)}' + return f'python-client-test-{resource}-{get_random_string(16)}' @overload From cb6fe9b144c3d5aea3d22883da53f39d3f84f013 Mon Sep 17 00:00:00 2001 From: Vlada Dusek Date: Thu, 16 Apr 2026 09:09:02 +0200 Subject: [PATCH 2/2] fix: add 63-char API name limit guard to get_random_resource_name Adopt the approach from apify-sdk-python that validates the generated resource name won't exceed the API limit of 63 characters. Co-Authored-By: Claude Opus 4.6 (1M context) --- tests/integration/_utils.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/tests/integration/_utils.py b/tests/integration/_utils.py index 14a62e8d..8a3e1f1f 100644 --- a/tests/integration/_utils.py +++ b/tests/integration/_utils.py @@ -64,9 +64,21 @@ def get_random_string(length: int = 10) -> str: return ''.join(secrets.choice(string.ascii_letters) for _ in range(length)) -def get_random_resource_name(resource: str) -> str: - """Generate a random resource name for test resources.""" - return f'python-client-test-{resource}-{get_random_string(16)}' +def get_random_resource_name(label: str) -> str: + """Generate a unique resource name containing the given label. + + Ensures the generated name does not exceed the API limit of 63 characters. + """ + name_template = 'python-client-test-{}-{}' + template_length = len(name_template.format('', '')) + api_name_limit = 63 + random_id_length = 8 + label_length_limit = api_name_limit - template_length - random_id_length + + label = label.replace('_', '-') + assert len(label) <= label_length_limit, f'Max label length is {label_length_limit}, but got {len(label)}' + + return name_template.format(label, get_crypto_random_object_id(random_id_length)) @overload