{"record":{"id":"502975cd053f6224","repo":"siyuan-note/siyuan","slug":"invalid-bazaar-package-rating-s","errorCode":null,"errorMessage":"invalid bazaar package rating: %s","messagePattern":"invalid bazaar package rating: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/bazaar/index.go","lineNumber":240,"sourceCode":"\t\t\tret.meta.RatingsAvailable = false\n\t\t} else {\n\t\t\tif !hasPackages {\n\t\t\t\treturn nil, errors.New(\"incomplete bazaar index metadata\")\n\t\t\t}\n\t\t\tif err = json.Unmarshal(packagesRaw, &ret.packages); nil != err {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tif nil == ret.packages {\n\t\t\t\treturn nil, errors.New(\"invalid bazaar index packages\")\n\t\t\t}\n\t\t\tfor packageName, pkg := range ret.packages {\n\t\t\t\tif !IsValidPackageName(packageName) || nil == pkg || !isValidBazaarRepo(pkg.Repo) || 0 > pkg.Downloads {\n\t\t\t\t\treturn nil, fmt.Errorf(\"invalid bazaar index package: %s\", packageName)\n\t\t\t\t}\n\t\t\t\tif nil != pkg.Rating {\n\t\t\t\t\trating, valid := normalizePackageRating(pkg.Rating)\n\t\t\t\t\tif !valid {\n\t\t\t\t\t\treturn nil, fmt.Errorf(\"invalid bazaar package rating: %s\", packageName)\n\t\t\t\t\t}\n\t\t\t\t\tpkg.Rating = rating\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else if hasPackages {\n\t\treturn nil, errors.New(\"incomplete bazaar index metadata\")\n\t}\n\n\tif !hasMeta || 2 == ret.meta.Schema || bazaarIndexSchema < ret.meta.Schema {\n\t\tfor rawRepo, rawStats := range raw {\n\t\t\tif \"meta\" == rawRepo || \"packages\" == rawRepo {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\trepo, valid := normalizeLegacyBazaarRepo(rawRepo)\n\t\t\tif !valid {\n\t\t\t\treturn nil, fmt.Errorf(\"invalid bazaar repository: %s\", rawRepo)\n\t\t\t}","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/bazaar/index.go#L222-L258","documentation":"A package entry in the index may include a rating object, which must pass normalizePackageRating (expected shape/ranges for the rating fields). An entry whose rating cannot be normalized aborts the parse for the whole index, with the package name in the message.","triggerScenarios":"parseBazaarIndex finds pkg.Rating non-nil for some package but normalizePackageRating returns valid=false — e.g. rating fields of the wrong type, out-of-range counts, or a malformed rating object published for that package.","commonSituations":"A stats aggregation bug on the bazaar server emitting a rating with unexpected field types; schema drift between publisher and the rating shape this client version understands; corrupted cached data used to build the index.","solutions":["Fix the offending package's rating data on the bazaar server so it matches the expected rating shape, or omit the rating field for it","Compare the publisher's rating serialization against normalizePackageRating's expectations and align the format","Check for a publisher/client version mismatch after a ratings-format change and roll back or upgrade accordingly","Retry after the index is republished with corrected data"],"exampleFix":"// index entry, before\n\"my-plugin\": {\"repo\": \"owner/my-plugin\", \"rating\": {\"count\": \"many\"}}\n// after\n\"my-plugin\": {\"repo\": \"owner/my-plugin\", \"rating\": {\"count\": 42}}","handlingStrategy":"validation","validationCode":"// validate rating shape before publishing\nif pkg.Rating != nil {\n    if _, valid := normalizePackageRating(pkg.Rating); !valid {\n        return fmt.Errorf(\"bad rating for %s\", name)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"invalid bazaar package rating\") {\n    // rating schema drift for that package; serve cached snapshot and fix publisher\n}","preventionTips":["Share the rating normalization code (or its schema contract) between publisher and client to prevent drift","Omit the rating field entirely rather than emitting a malformed object","Add per-package schema tests in the publisher's CI covering ratings"],"tags":["marketplace","validation","rating"],"backgroundTag":"unexpected-api-response-shape","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}