{"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/8641553a1f07374001902d3ce773285db1292b2d/kernel/bazaar/index.go#L239-L275","documentation":"When parsing the legacy portion of a bazaar index, every top-level key other than 'meta' and 'packages' must be a valid repository identifier (an 'owner/repo' GitHub path, optionally with a https://github.com/ prefix, case-normalized). parseBazaarIndex throws this error when normalizeLegacyBazaarRepo rejects a key.","triggerScenarios":"A legacy-format index JSON contains a top-level key like 'foo', 'https://github.com/', 'owner/repo/extra', or an empty string instead of a valid owner/repo repo key; the loop over raw map entries then fails validation.","commonSituations":"A corrupted or tampered index from a CDN; a custom index mirror emitting stats keyed by package name or URL variants the validator rejects; trailing slashes or uppercase/special characters in repo keys not accepted by isValidBazaarRepo.","solutions":["Inspect the index JSON keys and fix/replace the malformed repository key with a valid 'owner/repo' form","Re-fetch the index from the official bazaar stat server to rule out a stale/corrupted cache","If running a mirror, emit keys as 'owner/repo' (an optional 'https://github.com/' prefix is stripped automatically)","Check isValidBazaarRepo in kernel/bazaar for the exact accepted format and normalize your keys accordingly"],"exampleFix":"// before (index JSON)\n{\"my-plugin\": {\"downloads\": 5}}\n// after\n{\"https://github.com/siyuan-note/my-plugin\": {\"downloads\": 5}}","handlingStrategy":"validation","validationCode":"for key := range indexObj {\n\tif key == \"meta\" || key == \"packages\" { continue }\n\tif _, ok := normalizeLegacyBazaarRepo(key); !ok {\n\t\treturn fmt.Errorf(\"bad repo key: %s\", key)\n\t}\n}","typeGuard":"func isValidRepoKey(key string) bool {\n\t_, ok := normalizeLegacyBazaarRepo(key) // accepts 'owner/repo' with optional https://github.com/ prefix\n\treturn ok\n}","tryCatchPattern":"snapshot, err := parseBazaarIndex(data)\nif err != nil {\n\tif strings.HasPrefix(err.Error(), \"invalid bazaar repository:\") {\n\t\tlog.Errorf(\"index contains malformed repo key; refetch from official server\")\n\t}\n\treturn err\n}","preventionTips":["Emit legacy stats keys as 'owner/repo' identifiers","Strip https://github.com/ prefixes server-side or rely on normalizeLegacyBazaarRepo","Avoid keys with trailing slashes, empty strings, or non-GitHub URLs","Validate index JSON before publishing to a mirror"],"tags":["bazaar","json","marketplace","validation","repo"],"backgroundTag":"invalid-identifier-format","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}