diff --git a/plugins/edsm.py b/plugins/edsm.py index 7905f657f..9519d83f6 100644 --- a/plugins/edsm.py +++ b/plugins/edsm.py @@ -329,9 +329,14 @@ def credentials(cmdr: str) -> Optional[Tuple[str, str]]: cmdrs = [cmdr] config.set('edsm_cmdrs', cmdrs) - if cmdr in cmdrs and config.get_list('edsm_usernames') and config.get_list('edsm_apikeys'): + if (cmdr in cmdrs and (edsm_usernames := config.get_list('edsm_usernames')) + and (edsm_apikeys := config.get_list('edsm_apikeys'))): idx = cmdrs.index(cmdr) - return (config.get_list('edsm_usernames')[idx], config.get_list('edsm_apikeys')[idx]) + # The EDSM cmdr and apikey might not exist yet! + if idx >= len(edsm_usernames) or idx >= len(edsm_apikeys): + return None + + return (edsm_usernames[idx], edsm_apikeys[idx]) else: return None