Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/session/discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def _configure_file_mode(self, username: str | None = None) -> None:
Args:
username: If ``"use@file.com"``, switches the session to file-based mode.
"""
if username == "use@file.com":
if username.strip().lower() == "use@file.com":

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Claude Code Review

Bug: username is typed str | None and defaults to None. Hive(username=None) is allowed (session/__init__.py:38), and start_session passes config.get("username", self.config.username) here (discovery.py:192). If the username is None, None.strip() raises AttributeError, so start_session() crashes. The same happens if config={"username": None}. Before this PR, the == comparison handled None.

Suggested fix:

Suggested change
if username.strip().lower() == "use@file.com":
if username and username.strip().lower() == "use@file.com":

Also note that hive_auth_async.py:82 and hive_auth.py:114 still use the exact == "use@file.com" check, so the normalisation is inconsistent. No test was added for the new behaviour (mixed case, whitespace, None).

self.config.file = True

def add_list(self, entity_type: str, data: dict, **kwargs) -> Device | None:
Expand Down
Loading