{"record":{"id":"393e54e6de254341","repo":"siyuan-note/siyuan","slug":"too-many-package-names","errorCode":null,"errorMessage":"too many package names","messagePattern":"too many package names","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/bazaar_rating.go","lineNumber":93,"sourceCode":"\t}\n\tif 0 == len(eligiblePackageNames) {\n\t\treturn map[string]*bazaar.PackageRating{}, []string{}, nil\n\t}\n\tratings, available := bazaarRatingPublicPackageRatings(ctx, eligiblePackageNames)\n\tif !available {\n\t\treturn nil, nil, errors.New(\"marketplace package ratings are unavailable\")\n\t}\n\treturn ratings, eligiblePackageNames, nil\n}\n\n// GetInstalledBazaarPackageUserRatings 获取指定已安装官方包的当前用户评分。\nfunc GetInstalledBazaarPackageUserRatings(ctx context.Context, pkgType string,\n\tpackageNames []string) (userRatings map[string]int, eligiblePackageNames []string, err error) {\n\tif !isValidBazaarPackageType(pkgType) {\n\t\treturn nil, nil, errors.New(\"invalid package type\")\n\t}\n\tif bazaarPackageRatingBatchSize < len(packageNames) {\n\t\treturn nil, nil, errors.New(\"too many package names\")\n\t}\n\ttoken, err := bazaarRatingUserToken()\n\tif nil != err {\n\t\treturn nil, nil, err\n\t}\n\teligiblePackageNames, err = getInstalledOfficialBazaarPackageNames(ctx, pkgType, packageNames)\n\tif nil != err {\n\t\treturn nil, nil, err\n\t}\n\tif 0 == len(eligiblePackageNames) {\n\t\treturn map[string]int{}, []string{}, nil\n\t}\n\n\tuserRatings, err = requestBazaarPackageUserRatings(ctx, token, eligiblePackageNames)\n\tif nil != err {\n\t\treturn nil, nil, err\n\t}\n\treturn userRatings, eligiblePackageNames, nil","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/bazaar_rating.go#L75-L111","documentation":"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.","triggerScenarios":"Calling GetInstalledBazaarPackageUserRatings with more package names than bazaarPackageRatingBatchSize — e.g. passing every installed plugin at once instead of the visible page.","commonSituations":"UI requesting ratings for all installed packages in a single call; aggregated dashboards; tests exercising oversized batches (TestGetInstalledBazaarPackageUserRatingsRejectsOversizedBatch).","solutions":["Split packageNames into chunks of at most bazaarPackageRatingBatchSize and call per chunk.","Only request ratings for packages currently displayed (paginate before querying).","Increase the batch constant only if the cloud API contract allows larger batches.","Cache user ratings locally to reduce repeat batch sizes."],"exampleFix":"// before: one oversized call\nratings, _, err := model.GetInstalledBazaarPackageUserRatings(ctx, \"plugins\", allNames)\n// after: chunked calls\nconst chunk = model.BazaarPackageRatingBatchSize // exported size if available\nfor i := 0; i < len(allNames); i += 32 {\n    end := i + 32\n    if end > len(allNames) { end = len(allNames) }\n    part, _, err := model.GetInstalledBazaarPackageUserRatings(ctx, \"plugins\", allNames[i:end])\n    if err != nil { return err }\n    for k, v := range part { ratings[k] = v }\n}","handlingStrategy":"validation","validationCode":"if len(names) > bazaarPackageRatingBatchSize { return errors.New(\"batch too large; chunk the request\") }","typeGuard":null,"tryCatchPattern":"if err := model.GetInstalledBazaarPackageUserRatings(ctx, pkgType, names); err != nil {\n    if err.Error() == \"too many package names\" {\n        return chunkedQuery(ctx, pkgType, names) // split and merge\n    }\n    return err\n}","preventionTips":["Keep batches within bazaarPackageRatingBatchSize","Query ratings only for visible/paged packages","Merge chunked results into a single map"],"tags":["go","marketplace","rating","batch-limit"],"backgroundTag":"value-out-of-range","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}