fix: prevent segfault in login command when session doesn't exist

LoadSession() was returning nil when the session file didn't exist (first login).
The login command then tried to dereference nil when setting session.Token,
causing a panic. Now LoadSession() returns an empty Session with the path set,
so callers can always use the returned session.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-04-02 13:23:34 +02:00
parent 89432e608b
commit 24fb3a8b62

View File

@@ -22,7 +22,7 @@ func LoadSession() (*Session, error) {
data, err := os.ReadFile(path)
if err != nil {
if os.IsNotExist(err) {
return nil, nil
return &Session{path: path}, nil
}
return nil, err
}