{"record":{"id":"0b27c96e275ecf74","repo":"siyuan-note/siyuan","slug":"invalid-bazaar-index-package-s","errorCode":null,"errorMessage":"invalid bazaar index package: %s","messagePattern":"invalid bazaar index package: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/bazaar/index.go","lineNumber":235,"sourceCode":"\t\t}\n\t\tif \"\" == strings.TrimSpace(ret.meta.Generation) || 1 > ret.meta.PublishedAt {\n\t\t\treturn nil, errors.New(\"invalid bazaar index generation metadata\")\n\t\t}\n\t\tif bazaarIndexSchema < ret.meta.Schema {\n\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","sourceCodeStart":217,"sourceCodeEnd":253,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/bazaar/index.go#L217-L253","documentation":"Each entry in the packages map is validated: the key must be a valid package name (IsValidPackageName), the value must be non-nil, its repo must pass isValidBazaarRepo, and Downloads must be >= 0. The first entry failing any of these aborts parsing with the package name in the message, so a single bad package poisons the whole index.","triggerScenarios":"fetchBazaarIndexPath receives an index containing a package entry with an invalid name key, a null entry, a repo string that does not match owner/repo form, or a negative downloads count.","commonSituations":"An upstream package was renamed to a name violating the naming rules; a repo field contains a full URL instead of owner/repo; downloads metadata became negative after an aggregation bug.","solutions":["Fix the offending package entry in the bazaar index generator (name, repo, downloads)","Re-fetch the index after upstream repair","Remove the invalid package entry from the test fixture"],"exampleFix":"// before\n{\"packages\":{\"bad pkg\":{\"repo\":\"https://github.com/o/r\",\"downloads\":-1}}}\n// after\n{\"packages\":{\"good-pkg\":{\"repo\":\"o/r\",\"downloads\":10}}}","handlingStrategy":"validation","validationCode":"for (const [name, pkg] of Object.entries(idx.packages)) {\n  if (!/^[A-Za-z0-9-]+$/.test(name) || pkg == null || !/^[^/]+\\/[^/]+$/.test(pkg.repo) || pkg.downloads < 0) throw new Error(`invalid package entry: ${name}`)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate package names and repo slugs at package-registration time","Never store repo fields as full URLs; use owner/repo","Clamp or reject negative download counts at aggregation time"],"tags":["bazaar","validation","package-metadata","invalid-identifier"],"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"}