siyuan-note/siyuan · error

Account authentication failed, please login again

Error message

Account authentication failed, please login again

What it means

Conf.Language(31) resolves to 'Account authentication failed, please login again'. validateBazaarPackageRatingRequest0 throws it when Conf.GetUser() returns nil or the user has an empty UserToken, i.e. no SiYuan account is logged into this kernel. Rating marketplace packages requires an authenticated cloud account because the rating is stored server-side per user. Returned by both /api/bazaar/getBazaarPackageRating and /api/bazaar/setBazaarPackageRating.

Source

Thrown at kernel/model/bazaar_rating.go:219

	}
	if !bazaar.ApplyBazaarPackageRatingDistribution(region, packageName, distribution) {
		return nil, false, 0, errors.New("invalid rating distribution returned by cloud server")
	}

	rating, ratingAvailable = bazaarRatingAfterUpdate(ctx, region, packageName, distribution)
	return rating, ratingAvailable, data.Rating, nil
}

func validateBazaarPackageRatingRequest0(ctx context.Context, pkgType, packageName string) (token string, err error) {
	if !isValidBazaarPackageType(pkgType) {
		return "", errors.New("invalid package type")
	}
	if !bazaar.IsValidPackageName(packageName) {
		return "", errors.New("invalid package name")
	}
	user := Conf.GetUser()
	if nil == user || "" == user.UserToken {
		return "", errors.New(Conf.Language(31))
	}

	installedInfos, _, _, err := GetInstalledPackageInfos(pkgType)
	if nil != err {
		return "", err
	}
	installed := false
	for _, info := range installedInfos {
		if "" == info.Pkg.InvalidReason && packageName == info.Pkg.Name {
			installed = true
			break
		}
	}
	if !installed {
		return "", errors.New("marketplace package is not installed")
	}

	exists, err := bazaar.HasBazaarPackage(ctx, pkgType, packageName)

View on GitHub (pinned to afa823b6b4)

Solutions

  1. Log into a SiYuan account via Settings - Account, then retry
  2. Verify login state first via /api/setting/getAccount before calling the rating API
  3. For automation, skip rating calls when no account is configured instead of erroring

Example fix

// before
rating, available, userRating, err := model.SetBazaarPackageRating(ctx, "plugins", "my-plugin", 5)

// after: gate on login state first
if user := model.Conf.GetUser(); nil == user || "" == user.UserToken {
    return errors.New("login required before rating")
}
rating, available, userRating, err := model.SetBazaarPackageRating(ctx, "plugins", "my-plugin", 5)
Defensive patterns

Strategy: validation

Validate before calling

user := model.Conf.GetUser()
if nil == user || "" == user.UserToken {
    return errors.New("rating requires a logged-in SiYuan account")
}
// safe to call model.Get/SetBazaarPackageRating now

Type guard

func hasRatingAccount() bool {
    user := model.Conf.GetUser()
    return nil != user && "" != user.UserToken
}

Try / catch

if err != nil && strings.Contains(err.Error(), "please login again") {
    // no local session: prompt login; do not retry until the user authenticates
}

Prevention

When it happens

Trigger: Calling either rating endpoint while the user is logged out; account data cleared from conf after a logout or workspace reset; calling the model functions from headless/kernel-mode runs where no account session exists.

Common situations: Fresh installs or new workspaces where nobody logged in; users who logged out in Settings - Account; automation scripts hitting the API on a kernel with no account; token removed by workspace switching.

Understand the failure class

Related errors


AI-assisted analysis of siyuan-note/siyuan@afa823b6b4 (2026-08-18). Data as JSON: /api/errors/d28c9902863a40f4. Report an issue: GitHub.