Skip to content

Commit 953ac5f

Browse files
Tim Huffcursoragent
andcommitted
Exclude close() from CLI auto-registration.
Adding Groundlight.close for token-refresh lifecycle made the CLI crash on KeyError because close was not in _COMMAND_GROUPS. Also harden expires_at timezone comparisons. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent e28aedc commit 953ac5f

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

src/groundlight/cli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ def wrapper(*args, **kwargs):
168168
# Methods that should not be exposed as CLI commands. Add a method here if its signature
169169
# cannot be cleanly represented as CLI arguments or if it is not useful as a shell command.
170170
_CLI_EXCLUDED_METHODS = {
171+
"close", # lifecycle helper for the SDK client; not useful as a shell command
171172
"create_roi", # returns an ROI object that must be passed to another API call; not useful standalone
172173
"get_raw_headers", # returns the API token in plaintext
173174
"make_generic_api_request",

src/groundlight/token_manager.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,10 @@ def _install_slot(self, slot: TokenSlot) -> None:
358358
self._set_api_token(slot.current.raw_key)
359359

360360
def _is_expired(self, token: CachedToken) -> bool:
361-
return _utcnow() >= token.expires_at
361+
expires_at = token.expires_at
362+
if expires_at.tzinfo is None:
363+
expires_at = expires_at.replace(tzinfo=timezone.utc)
364+
return _utcnow() >= expires_at.astimezone(timezone.utc)
362365

363366
def _read_slot(self) -> Optional[TokenSlot]:
364367
if not self._slot_path.exists():

0 commit comments

Comments
 (0)