From c744949d9192f04eaf2696ce4100555dccdb799a Mon Sep 17 00:00:00 2001 From: Andrew Gunnerson Date: Sun, 12 Apr 2026 16:12:05 -0400 Subject: [PATCH] mega: fix crash when logging in with previous auth keys fails When Mega.LoginWithKeys() fails to make the API request, it leaves the object in a state where Mega.FS.root is nil because it could never query any information about the filesystem tree. An easy way for this to happen is if the device is not connected to the internet. Previously, these failures would be ignored, but Fs.findRoot() on the rclone side is written in a way that assumes the go-meta filesystem will have a non-nil root. This leads to an immediate nil pointer dereference when NewFs() calls Fs.findRoot(). This commit fixes the problem by making LoginWithKeys() failures hard failures, similar to the MultiFactorLogin() path. Signed-off-by: Andrew Gunnerson --- backend/mega/mega.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/mega/mega.go b/backend/mega/mega.go index 4eda36a44..b0ef2e10b 100644 --- a/backend/mega/mega.go +++ b/backend/mega/mega.go @@ -284,7 +284,7 @@ func NewFs(ctx context.Context, name, root string, m configmap.Mapper) (fs.Fs, e } err = srv.LoginWithKeys(opt.SessionID, decodedMasterKey) if err != nil { - fs.Debugf(f, "login with previous auth keys failed: %v", err) + return nil, fmt.Errorf("login with previous auth keys failed: %w", err) } } }