Skip to content

Commit 7be00ff

Browse files
committed
Respond to comments
Signed-off-by: Alan Cha <Alan.cha1@ibm.com>
1 parent aa271a9 commit 7be00ff

3 files changed

Lines changed: 23 additions & 19 deletions

File tree

a2a/slack_researcher/slack_researcher/auth.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def __init__(self):
4848
else:
4949
self.claims_options["aud"] = {"essential": True, "value": settings.CLIENT_ID}
5050
if settings.ISSUER is None:
51-
logger.debug(f"ISSUER env var no set. No issuer check will be performed")
51+
logger.debug(f"ISSUER env var not set. No issuer check will be performed")
5252
else:
5353
self.claims_options["iss"] = {"essential": True, "value": settings.ISSUER}
5454

a2a/slack_researcher/slack_researcher/config.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,21 @@ def get_client_id() -> str:
1616
try:
1717
with open(jwt_file_path, "r") as file:
1818
content = file.read()
19-
2019
except FileNotFoundError:
21-
print(f"Error: The file {jwt_file_path} was not found.")
22-
except Exception as e:
23-
print(f"An error occurred: {e}")
20+
raise Exception(f"SVID JWT file {jwt_file_path} not found.")
2421

2522
if content is None or content.strip() == "":
26-
raise Exception(f"No content read from SVID JWT.")
23+
raise Exception(f"No content in SVID JWT file {jwt_file_path}.")
24+
25+
try:
26+
decoded = jwt.decode(content, options={"verify_signature": False})
27+
except jwt.DecodeError:
28+
raise ValueError(f"Failed to decode SVID JWT file {jwt_file_path}.")
2729

28-
decoded = jwt.decode(content, options={"verify_signature": False})
29-
if "sub" not in decoded:
30-
raise Exception('SVID JWT does not contain a "sub" claim.')
31-
return decoded["sub"]
30+
try:
31+
return decoded["sub"]
32+
except KeyError:
33+
raise KeyError('SVID JWT is missing required "sub" claim.')
3234

3335
class Settings(BaseSettings):
3436
# static path for client secret file

mcp/slack_tool/slack_tool.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,21 @@ def get_client_id() -> str:
1818
try:
1919
with open(jwt_file_path, "r") as file:
2020
content = file.read()
21-
2221
except FileNotFoundError:
23-
print(f"Error: The file {jwt_file_path} was not found.")
24-
except Exception as e:
25-
print(f"An error occurred: {e}")
22+
raise Exception(f"SVID JWT file {jwt_file_path} not found.")
2623

2724
if content is None or content.strip() == "":
28-
raise Exception(f"No content read from SVID JWT.")
25+
raise Exception(f"No content in SVID JWT file {jwt_file_path}.")
2926

30-
decoded = jwt.decode(content, options={"verify_signature": False})
31-
if "sub" not in decoded:
32-
raise Exception('SVID JWT does not contain a "sub" claim.')
33-
return decoded["sub"]
27+
try:
28+
decoded = jwt.decode(content, options={"verify_signature": False})
29+
except jwt.DecodeError:
30+
raise ValueError(f"Failed to decode SVID JWT file {jwt_file_path}.")
31+
32+
try:
33+
return decoded["sub"]
34+
except KeyError:
35+
raise KeyError('SVID JWT is missing required "sub" claim.')
3436

3537
logger = logging.getLogger(__name__)
3638
logging.basicConfig(level=os.getenv("LOG_LEVEL", "DEBUG"), stream=sys.stdout, format='%(levelname)s: %(message)s')

0 commit comments

Comments
 (0)