{"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":97,"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\t// 仅返回查询成功的包，失败项保持未加载状态，允许后续重新查询。","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/model/bazaar_rating.go#L79-L115","documentation":"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.","triggerScenarios":"Calling GetInstalledBazaarPackageUserRatings with a slice longer than 1024 package names.","commonSituations":"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.","solutions":["Split the request into batches of at most 1024 names","Filter to actually installed/visible packages before querying","Aggregate results from multiple batch calls client-side"],"exampleFix":"// before\nratings, _, err := model.GetInstalledBazaarPackageUserRatings(ctx, \"plugins\", allNames) // len > 1024\n// after\nconst batch = 1024\nfor i := 0; i < len(allNames); i += batch {\n    end := min(i+batch, len(allNames))\n    ratings, _, err := model.GetInstalledBazaarPackageUserRatings(ctx, \"plugins\", allNames[i:end])\n    ...\n}","handlingStrategy":"validation","validationCode":"if len(packageNames) > 1024 {\n    return errors.New(\"batch exceeds bazaar rating limit of 1024 names\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Chunk package lists to <= 1024 before calling","Deduplicate names and filter to installed packages first","Add a unit test asserting the batch-size guard"],"tags":["validation","limit","batching"],"backgroundTag":"payload-too-large","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}