From 1770a1e0f444848725009f3976a013d1f9e99f1c Mon Sep 17 00:00:00 2001 From: "zhurenzhu.zrz" Date: Mon, 3 Jul 2023 09:13:47 +0800 Subject: [PATCH] raise error while ak is empty --- aliyun/log/auth.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/aliyun/log/auth.py b/aliyun/log/auth.py index 9ef0b9f7..abbd720c 100644 --- a/aliyun/log/auth.py +++ b/aliyun/log/auth.py @@ -68,7 +68,7 @@ def sign_request(self, method, resource, params, headers, body): if body: headers['Content-MD5'] = Util.cal_md5(body) if not self.access_key_secret: - return six.b('') + raise ValueError('invalid access_key_secret:{}'.format(self.access_key_secret)) content = method + '\n' if 'Content-MD5' in headers: content += headers['Content-MD5'] @@ -90,6 +90,8 @@ def __init__(self, access_key_id, access_key_secret, region): self._region = region def sign_request(self, method, resource, params, headers, body): + if not self.access_key_secret: + raise ValueError('invalid access_key_secret:{}'.format(self.access_key_secret)) current_time = datetime.utcnow().strftime("%Y%m%dT%H%M%SZ") headers['Authorization'] = self._do_sign_request(method, resource, params, headers, body, current_time)