IceWhaleTech/CasaOS · error

e.Error.Message

Error message

e.Error.Message

What it means

The OneDrive API returned an error payload (the TokenErr struct's Error field was non-empty) during an authenticated request, and the driver surfaces the endpoint's Message field verbatim. Adjacent logic auto-recovers InvalidAuthenticationToken by refreshing the access token and retrying once; any other error code is fatal with this message.

Source

Thrown at drivers/onedrive/util.go:144

	}
	if resp != nil {
		req.SetResult(resp)
	}
	var e RespErr
	req.SetError(&e)
	res, err := req.Execute(method, url)
	if err != nil {
		return nil, err
	}
	if e.Error.Code != "" {
		if e.Error.Code == "InvalidAuthenticationToken" {
			err = d.refreshToken()
			if err != nil {
				return nil, err
			}
			return d.Request(url, method, callback, resp)
		}
		return nil, errors.New(e.Error.Message)
	}
	return res.Body(), nil
}

func GetConfig() Onedrive {
	config := Onedrive{}
	config.ClientID = client_id
	config.ClientSecret = client_secret
	config.RootFolderID = "/"
	config.AuthUrl = "https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=" + client_id + "&response_type=code&redirect_uri=https%3A%2F%2Fcloudoauth.files.casaos.app&scope=offline_access+files.readwrite.all&state=${HOST}%2Fv1%2Frecover%2FOnedrive"
	config.Icon = "./img/driver/OneDrive.svg"
	config.Region = "global"
	config.RedirectUri = "https://cloudoauth.files.casaos.app"

	return config
}

View on GitHub (pinned to 0d3b2f444e)

Solutions

  1. Match the text in the error message to the OneDrive error code table (itemNotFound, accessDenied, etc.) — the Code determines the real fix, but only the Message is surfaced, so log the body too.
  2. For itemNotFound: refresh the parent listing — the item was moved or deleted by another client.
  3. For accessDenied/scope errors: re-authorize with Files.ReadWrite.All and confirm the right account/region.
  4. For throttling: back off and retry; Microsoft returns Retry-After headers.

Example fix

// before
return nil, errors.New(e.Error.Message)

// after (surface the code for diagnosability)
return nil, fmt.Errorf("onedrive: %s: %s", e.Error.Code, e.Error.Message)
Defensive patterns

Strategy: try-catch

Try / catch

body, err := d.Request(url, method, cb, resp)
if err != nil {
	// invalid_grant-style token failures are re-thrown after the built-in refresh retry;
	// distinguish retryable (throttling) from permanent (notFound/accessDenied) via message
	if strings.Contains(err.Error(), "activityLimitReached") {
		time.Sleep(30 * time.Second) // honor Retry-After
		return d.Request(url, method, cb, resp)
	}
	return err
}

Prevention

When it happens

Trigger: Any Request() call (list, upload, download, create folder) that returns an error body with e.Error.Code set — e.g. 'itemNotFound', 'accessDenied', 'quotaLimitReached', 'nameAlreadyExists' — while the Bearer token is still valid.

Common situations: The target path/item no longer exists (deleted or moved); the granted scope lacks permission for the operation; OneDrive personal vs business region mismatch; throttling (activityLimitReached) under heavy use.

Related errors


AI-assisted analysis of IceWhaleTech/CasaOS@0d3b2f444e (2026-08-15). Data as JSON: /api/errors/dbb49b19c2501c0f. Report an issue: GitHub.