siyuan-note/siyuan · error

too many package names

Error message

too many package names

What it means

GetInstalledBazaarPackageUserRatings rejects the request when more than bazaarPackageRatingBatchSize (1024) package names are supplied, to bound cloud request fan-out. The check runs before any network I/O.

Solutions

  1. Split the request into batches of at most 1024 names
  2. Filter to actually installed/visible packages before querying
  3. Aggregate results from multiple batch calls client-side

Example fix

// before
ratings, _, err := model.GetInstalledBazaarPackageUserRatings(ctx, "plugins", allNames) // len > 1024
// after
const batch = 1024
for i := 0; i < len(allNames); i += batch {
    end := min(i+batch, len(allNames))
    ratings, _, err := model.GetInstalledBazaarPackageUserRatings(ctx, "plugins", allNames[i:end])
    ...
}
Defensive patterns

Strategy: validation

Validate before calling

if len(packageNames) > 1024 {
    return errors.New("batch exceeds bazaar rating limit of 1024 names")
}

Prevention

When it happens

Trigger: Calling GetInstalledBazaarPackageUserRatings with a slice longer than 1024 package names.

Common situations: Bulk-querying ratings for every installed package plus historical names without batching; a UI bug passing the full package catalog instead of the visible page.

Understand the failure class

Background: payload too large / request exceeds maximum size: why libraries cap bytes and how to fix oversize payloads — this error's family across 50 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/393e54e6de254341. Report an issue: GitHub.

Appendix: source

Thrown at kernel/model/bazaar_rating.go:97

	}
	if 0 == len(eligiblePackageNames) {
		return map[string]*bazaar.PackageRating{}, []string{}, nil
	}
	ratings, available := bazaarRatingPublicPackageRatings(ctx, eligiblePackageNames)
	if !available {
		return nil, nil, errors.New("marketplace package ratings are unavailable")
	}
	return ratings, eligiblePackageNames, nil
}

// GetInstalledBazaarPackageUserRatings 获取指定已安装官方包的当前用户评分。
func GetInstalledBazaarPackageUserRatings(ctx context.Context, pkgType string,
	packageNames []string) (userRatings map[string]int, eligiblePackageNames []string, err error) {
	if !isValidBazaarPackageType(pkgType) {
		return nil, nil, errors.New("invalid package type")
	}
	if bazaarPackageRatingBatchSize < len(packageNames) {
		return nil, nil, errors.New("too many package names")
	}
	token, err := bazaarRatingUserToken()
	if nil != err {
		return nil, nil, err
	}
	eligiblePackageNames, err = getInstalledOfficialBazaarPackageNames(ctx, pkgType, packageNames)
	if nil != err {
		return nil, nil, err
	}
	if 0 == len(eligiblePackageNames) {
		return map[string]int{}, []string{}, nil
	}

	userRatings, err = requestBazaarPackageUserRatings(ctx, token, eligiblePackageNames)
	if nil != err {
		return nil, nil, err
	}
	// 仅返回查询成功的包,失败项保持未加载状态,允许后续重新查询。

View on GitHub (pinned to 9f775e8a12)