{"record":{"id":"e38e949cda7292a0","repo":"siyuan-note/siyuan","slug":"invalid-bazaar-repository-s","errorCode":null,"errorMessage":"invalid bazaar repository: %s","messagePattern":"invalid bazaar repository: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/bazaar/index.go","lineNumber":257,"sourceCode":"\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}\n\t\t\tstats := &bazaarStats{}\n\t\t\tif err = json.Unmarshal(rawStats, stats); nil != err {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tif 0 > stats.Downloads {\n\t\t\t\treturn nil, fmt.Errorf(\"invalid bazaar downloads: %s\", rawRepo)\n\t\t\t}\n\t\t\tif current := ret.legacyStats[repo]; nil != current {\n\t\t\t\tif stats.Downloads > int(^uint(0)>>1)-current.Downloads {\n\t\t\t\t\treturn nil, fmt.Errorf(\"bazaar downloads overflow: %s\", repo)\n\t\t\t\t}\n\t\t\t\tcurrent.Downloads += stats.Downloads\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tret.legacyStats[repo] = stats\n\t\t}\n\t}","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/bazaar/index.go#L239-L275","documentation":"In the legacy/future-schema path (no meta, or schema == 2 handled separately, or schema beyond supported), every top-level key other than \"meta\" and \"packages\" is treated as a repository name carrying legacy download stats. Each is run through normalizeLegacyBazaarRepo; a key that does not normalize to a valid bazaar repository aborts parsing with the raw key in the message.","triggerScenarios":"fetchBazaarIndexPath receives a legacy-style index containing a top-level key that is not meta/packages and not a recognizable repository (e.g. a typo, a URL, or an unexpected field like \"error\" or \"status\").","commonSituations":"The endpoint returned an error envelope (e.g. {\"message\":\"rate limited\"}) instead of the index; an aggregator injected metadata fields into the legacy map; a fixture includes a test-only key.","solutions":["Remove or rename the non-repository top-level key in the index payload","Ensure the endpoint returns the index rather than an error envelope (check HTTP status)","Move auxiliary metadata under the reserved meta/packages keys or into schema 2 format"],"exampleFix":"// before\n{\"siyuan-note/siyuan\":{\"downloads\":100},\"status\":\"ok\"}\n// after\n{\"siyuan-note/siyuan\":{\"downloads\":100}}","handlingStrategy":"validation","validationCode":"for (const key of Object.keys(idx)) {\n  if (key !== \"meta\" && key !== \"packages\" && !/^[^/]+\\/[^/]+$/.test(key)) throw new Error(`unexpected top-level key: ${key}`)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify HTTP status before parsing so error envelopes are not treated as indexes","Restrict legacy index payloads to known repository keys only","Use reserved keys (meta/packages) for any new metadata"],"tags":["bazaar","legacy-format","repository","validation"],"backgroundTag":"unexpected-response-shape","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"}