{"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/9f775e8a12daef8255556097396f9b2739078892/kernel/bazaar/index.go#L222-L258","documentation":"If a package entry carries a rating, it is passed through normalizePackageRating, which returns a validity flag. An unnormalizable rating (wrong shape, out-of-range values) aborts parsing with the package name in the message. Ratings are optional per package but must be well-formed when present.","triggerScenarios":"fetchBazaarIndexPath receives an index whose packages.<name>.rating has an unexpected shape (e.g. wrong field types, star counts out of range) so normalizePackageRating reports invalid.","commonSituations":"An index generator changed its rating schema; a hand-edited fixture has a malformed rating object; a partially upgraded server emits ratings in the old format.","solutions":["Fix the rating object shape/values for the named package in the index generator","Omit the rating field entirely for that package if no valid data exists","Re-fetch the index after upstream repair"],"exampleFix":"// before\n{\"packages\":{\"pkg\":{\"repo\":\"o/r\",\"downloads\":5,\"rating\":{\"stars\":\"many\"}}}}\n// after\n{\"packages\":{\"pkg\":{\"repo\":\"o/r\",\"downloads\":5,\"rating\":{\"stars\":4.5,\"count\":100}}}}","handlingStrategy":"validation","validationCode":"if (pkg.rating != null && !(typeof pkg.rating.stars === \"number\" && pkg.rating.stars >= 0 && pkg.rating.stars <= 5)) throw new Error(\"malformed rating\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Omit the rating field when no valid rating data exists","Keep the rating producer's schema aligned with normalizePackageRating's expectations","Add rating shape tests to index generation CI"],"tags":["bazaar","rating","validation","type-mismatch"],"backgroundTag":"schema-validation-failed","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"}