Skip to content

Commit

Permalink
CRAYSAT-1392: Graceful handle of token expiry
Browse files Browse the repository at this point in the history
During the sat status execution if the user token is expired, there is a traceback which comes as the output. Hence graceful handling of the token expiry is added to inform the user.
  • Loading branch information
shivaprasad-metimath committed Aug 14, 2024
1 parent 7088e90 commit 93c43d4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [3.30.1] - 2024-08-13

### Fixed
- When the token used to access the API gateway is expired, log a helpful error
message instructing the user to reauthenticate with `sat auth` and then exit
instead of printing a traceback and exiting.

## [3.30.0] - 2024-08-09

### Changed
Expand Down
9 changes: 7 additions & 2 deletions sat/main.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# MIT License
#
# (C) Copyright 2019-2023 Hewlett Packard Enterprise Development LP
# (C) Copyright 2019-2024 Hewlett Packard Enterprise Development LP
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
Expand Down Expand Up @@ -32,6 +32,7 @@

import argcomplete

from oauthlib.oauth2 import InvalidGrantError
from sat.config import ConfigFileExistsError, DEFAULT_CONFIG_PATH, generate_default_config, load_config
from sat.warnings import configure_insecure_request_warnings
from sat.logging import bootstrap_logging, configure_logging
Expand Down Expand Up @@ -119,7 +120,11 @@ def main():
args.command, args.command)
sys.exit(1)

subcommand(args)
try:
subcommand(args)
except InvalidGrantError:
LOGGER.error("The token is not active or is invalid. "
"Please re-authenticate using 'sat auth' to obtain a new token")

except KeyboardInterrupt:
LOGGER.info("Received keyboard interrupt; quitting.", exc_info=True)
Expand Down

0 comments on commit 93c43d4

Please sign in to comment.