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:
@@ -22,7 +22,7 @@ func LoadSession() (*Session, error) {
|
|||||||
data, err := os.ReadFile(path)
|
data, err := os.ReadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
return nil, nil
|
return &Session{path: path}, nil
|
||||||
}
|
}
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user