siyuan-note/siyuan · error

too many package names

Error message

too many package names

What it means

GetInstalledBazaarPackageUserRatings enforces a maximum batch size (bazaarPackageRatingBatchSize) on the number of package names sent to the cloud in one request. When len(packageNames) exceeds this limit it returns 'too many package names'. The cloud user-rating endpoint only accepts bounded batches.

Source

Thrown at kernel/model/bazaar_rating.go:93

	}
	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
	}
	return userRatings, eligiblePackageNames, nil

View on GitHub (pinned to 8641553a1f)

Solutions

  1. Split packageNames into chunks of at most bazaarPackageRatingBatchSize and call per chunk.
  2. Only request ratings for packages currently displayed (paginate before querying).
  3. Increase the batch constant only if the cloud API contract allows larger batches.
  4. Cache user ratings locally to reduce repeat batch sizes.

Example fix

// before: one oversized call
ratings, _, err := model.GetInstalledBazaarPackageUserRatings(ctx, "plugins", allNames)
// after: chunked calls
const chunk = model.BazaarPackageRatingBatchSize // exported size if available
for i := 0; i < len(allNames); i += 32 {
    end := i + 32
    if end > len(allNames) { end = len(allNames) }
    part, _, err := model.GetInstalledBazaarPackageUserRatings(ctx, "plugins", allNames[i:end])
    if err != nil { return err }
    for k, v := range part { ratings[k] = v }
}
Defensive patterns

Strategy: validation

Validate before calling

if len(names) > bazaarPackageRatingBatchSize { return errors.New("batch too large; chunk the request") }

Try / catch

if err := model.GetInstalledBazaarPackageUserRatings(ctx, pkgType, names); err != nil {
    if err.Error() == "too many package names" {
        return chunkedQuery(ctx, pkgType, names) // split and merge
    }
    return err
}

Prevention

When it happens

Trigger: Calling GetInstalledBazaarPackageUserRatings with more package names than bazaarPackageRatingBatchSize — e.g. passing every installed plugin at once instead of the visible page.

Common situations: UI requesting ratings for all installed packages in a single call; aggregated dashboards; tests exercising oversized batches (TestGetInstalledBazaarPackageUserRatingsRejectsOversizedBatch).

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


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