From 66d3f4f2daf33f912eec22b56899e5a0e224cd48 Mon Sep 17 00:00:00 2001 From: Gyubong Date: Tue, 10 Dec 2024 12:30:09 +0900 Subject: [PATCH 1/5] fix: Broken CLI test --- src/ai/backend/client/auth.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ai/backend/client/auth.py b/src/ai/backend/client/auth.py index 5719a0e18e..f7cc93d64b 100644 --- a/src/ai/backend/client/auth.py +++ b/src/ai/backend/client/auth.py @@ -5,6 +5,7 @@ import secrets from datetime import datetime from typing import Mapping, Tuple +from urllib.parse import urlparse import attrs from Crypto.Cipher import AES @@ -50,7 +51,7 @@ def generate_signature( Generates the API request signature from the given parameters. """ hash_type = hash_type - hostname = endpoint._val.netloc # type: ignore + hostname = urlparse(str(endpoint)).netloc body_hash = hashlib.new(hash_type, b"").hexdigest() sign_str = "{}\n{}\n{}\nhost:{}\ncontent-type:{}\nx-backendai-version:{}\n{}".format( # noqa From 70f943e2bd4a23b57e7beae262e0fc344d93cfe7 Mon Sep 17 00:00:00 2001 From: Gyubong Lee Date: Tue, 10 Dec 2024 04:19:23 +0000 Subject: [PATCH 2/5] chore: Add news fragment --- changes/3225.fix.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changes/3225.fix.md diff --git a/changes/3225.fix.md b/changes/3225.fix.md new file mode 100644 index 0000000000..70e7ccd602 --- /dev/null +++ b/changes/3225.fix.md @@ -0,0 +1 @@ +Fix CLI test failures from `yarl.URL._val` type change. \ No newline at end of file From 118cee33eb207746cf7eea02bdde41e44b6613d9 Mon Sep 17 00:00:00 2001 From: Gyubong Lee Date: Tue, 10 Dec 2024 16:17:08 +0900 Subject: [PATCH 3/5] Rename 3225.fix.md to 3235.fix.md --- changes/3225.fix.md | 1 - changes/3235.fix.md | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 changes/3225.fix.md create mode 100644 changes/3235.fix.md diff --git a/changes/3225.fix.md b/changes/3225.fix.md deleted file mode 100644 index 70e7ccd602..0000000000 --- a/changes/3225.fix.md +++ /dev/null @@ -1 +0,0 @@ -Fix CLI test failures from `yarl.URL._val` type change. \ No newline at end of file diff --git a/changes/3235.fix.md b/changes/3235.fix.md new file mode 100644 index 0000000000..b5cc30187c --- /dev/null +++ b/changes/3235.fix.md @@ -0,0 +1 @@ +Fix CLI test failures from `yarl.URL._val` type change. From b7e53d8f88a64a611e38a7ea4cb1cb870201f60f Mon Sep 17 00:00:00 2001 From: Gyubong Lee Date: Tue, 10 Dec 2024 18:28:15 +0900 Subject: [PATCH 4/5] Update 3235.fix.md --- changes/3235.fix.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changes/3235.fix.md b/changes/3235.fix.md index b5cc30187c..14277efc9a 100644 --- a/changes/3235.fix.md +++ b/changes/3235.fix.md @@ -1 +1 @@ -Fix CLI test failures from `yarl.URL._val` type change. +Fix CLI test failures caused by `yarl.URL._val` type change. From 48902a144082d4314872a7b91c8ef9f5e4e2a358 Mon Sep 17 00:00:00 2001 From: Gyubong Lee Date: Thu, 12 Dec 2024 01:43:53 +0000 Subject: [PATCH 5/5] fix: Use `raw_authority` --- src/ai/backend/client/auth.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ai/backend/client/auth.py b/src/ai/backend/client/auth.py index f7cc93d64b..a9cec5fdee 100644 --- a/src/ai/backend/client/auth.py +++ b/src/ai/backend/client/auth.py @@ -5,7 +5,6 @@ import secrets from datetime import datetime from typing import Mapping, Tuple -from urllib.parse import urlparse import attrs from Crypto.Cipher import AES @@ -51,7 +50,7 @@ def generate_signature( Generates the API request signature from the given parameters. """ hash_type = hash_type - hostname = urlparse(str(endpoint)).netloc + hostname = endpoint.raw_authority body_hash = hashlib.new(hash_type, b"").hexdigest() sign_str = "{}\n{}\n{}\nhost:{}\ncontent-type:{}\nx-backendai-version:{}\n{}".format( # noqa