Skip to content

Commit 0f7b2d7

Browse files
committed
DEVSU-2797 - improve error message logging when graphkb_conn is made with graphkb_url None
1 parent e95203c commit 0f7b2d7

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

pori_python/graphkb/util.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,8 @@ def login_demo(self) -> None:
222222
1. get a first token from KeyCloak using username and password; self.login_demo()
223223
2. get a second token from the GraphKB API using keyCloakToken; self.login()
224224
"""
225+
if not self.url:
226+
raise ValueError("no self.url set - cannot make a login demo")
225227
url_parts = urlsplit(self.url)
226228
base_url = f"{url_parts.scheme}://{url_parts.netloc}"
227229

@@ -251,7 +253,8 @@ def login(self, username: str, password: str, pori_demo: bool = False) -> None:
251253
read_timeout = 61
252254

253255
# KBDEV-1328. Alt. GraphKB login for GSC's PORI online demo
254-
if pori_demo or "pori-demo" in self.url:
256+
if self.url and (pori_demo or "pori-demo" in self.url):
257+
logger.warning(f"login demo")
255258
self.login_demo()
256259

257260
# use requests package directly to avoid recursion loop on login failure

pori_python/ipr/main.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -417,14 +417,14 @@ def ipr_report(
417417
)
418418

419419
# GKB CONNECTION
420+
gkb_user = graphkb_username if graphkb_username else username
421+
gkb_pass = graphkb_password if graphkb_password else password
420422
if graphkb_url:
421423
logger.info(f"connecting to graphkb: {graphkb_url}")
422424
graphkb_conn = GraphKBConnection(graphkb_url)
423425
else:
424-
graphkb_conn = GraphKBConnection()
425-
426-
gkb_user = graphkb_username if graphkb_username else username
427-
gkb_pass = graphkb_password if graphkb_password else password
426+
# graphkb_conn = GraphKBConnection() # This will just error on trying to login
427+
raise ValueError("graphkb_url is required")
428428

429429
graphkb_conn.login(gkb_user, gkb_pass)
430430

0 commit comments

Comments
 (0)