{"record":{"id":"5563f41878fb4258","repo":"siyuan-note/siyuan","slug":"invalid-bazaar-index-schema-d","errorCode":null,"errorMessage":"invalid bazaar index schema: %d","messagePattern":"invalid bazaar index schema: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/bazaar/index.go","lineNumber":216,"sourceCode":"\tif err = json.Unmarshal(data, &raw); nil != err {\n\t\treturn nil, err\n\t}\n\tif nil == raw {\n\t\treturn nil, errors.New(\"invalid null bazaar index\")\n\t}\n\tret = &bazaarIndexSnapshot{\n\t\tpackages:    map[string]*bazaarIndexPackage{},\n\t\tlegacyStats: map[string]*bazaarStats{},\n\t}\n\n\tmetaRaw, hasMeta := raw[\"meta\"]\n\tpackagesRaw, hasPackages := raw[\"packages\"]\n\tif hasMeta {\n\t\tif err = json.Unmarshal(metaRaw, &ret.meta); nil != err {\n\t\t\treturn nil, err\n\t\t}\n\t\tif 2 > ret.meta.Schema {\n\t\t\treturn nil, fmt.Errorf(\"invalid bazaar index schema: %d\", ret.meta.Schema)\n\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 {","sourceCodeStart":198,"sourceCodeEnd":234,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/bazaar/index.go#L198-L234","documentation":"The bazaar index carries a meta.schema version and the parser requires schema >= 2. An index announcing an older schema (0 or 1 in meta) is rejected because its meta layout predates the supported contract. The parser cannot safely interpret packages/ratings from an obsolete schema.","triggerScenarios":"parseBazaarIndex reads an index whose meta unmarshals with meta.Schema < 2 — the server published a legacy or malformed index where meta.schema was omitted (zero value) or set to 1.","commonSituations":"A bazaar index publisher regressed to an old format; a test fixture or local mock server serving schema-1 data; a corrupted index where meta.schema is missing so it decodes as 0.","solutions":["Update the bazaar server to publish index schema >= 2 with a correct meta block","If you run a local mirror/mock of the index, regenerate it with the current schema-2 format (meta with schema, generation, publishedAt)","Check whether a broken deploy rolled back the index format and restore the current publisher","Upgrade SiYuan is not applicable here (this check demands schema >= 2, i.e. new data with old client gives error 255/forward-compat instead) — the fix is on the data side"],"exampleFix":"// server-side index meta\n// before\n{\"meta\": {\"schema\": 1, ...}}\n// after\n{\"meta\": {\"schema\": 2, \"generation\": \"2026-09-11T00:00:00Z\", \"publishedAt\": 1757548800, ...}}","handlingStrategy":"validation","validationCode":"// validate the published index meta before upload\nvar idx struct{ Meta struct{ Schema int `json:\"schema\"` } `json:\"meta\"` }\nif json.Unmarshal(body, &idx) != nil || idx.Meta.Schema < 2 {\n    return errors.New(\"index schema must be >= 2\")\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"invalid bazaar index schema\") {\n    // reject the snapshot, keep serving the cached one; fix the publisher\n}","preventionTips":["Pin the index publisher to the schema-2 format and add a CI check on published JSON","Never roll back the publisher to an older index format without coordinating client releases","Include meta.schema explicitly — omitted fields decode as 0 and fail this check"],"tags":["marketplace","schema","versioning"],"backgroundTag":"schema-validation-failed","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"}