{"record":{"id":"6f8e5a6853c2feff","repo":"siyuan-note/siyuan","slug":"incomplete-bazaar-index-metadata","errorCode":null,"errorMessage":"incomplete bazaar index metadata","messagePattern":"incomplete bazaar index metadata","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/bazaar/index.go","lineNumber":225,"sourceCode":"\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 {\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}","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/bazaar/index.go#L207-L243","documentation":"This error is thrown in two complementary cases: (1) the payload has meta with schema in the supported range (2..bazaarIndexSchema) but no `packages` key, or (2) the payload has a `packages` key but no `meta` key. A schema-2+ index must carry both meta and packages; either alone is incomplete.","triggerScenarios":"fetchBazaarIndexPath receives {\"meta\":{...}} without \"packages\", or {\"packages\":{...}} without \"meta\"; a truncated JSON object; a fixture with one of the two keys removed.","commonSituations":"An index builder dropped the packages section; an old format writer produced packages-only payloads; manual editing of a cached index removed a key.","solutions":["Regenerate the index including both meta and packages top-level keys","Re-fetch the index from the official endpoint","Fix the fixture to include both keys"],"exampleFix":"// before\n{\"meta\":{\"schema\":2,\"generation\":\"g1\",\"publishedAt\":1789000000}}\n// after\n{\"meta\":{\"schema\":2,\"generation\":\"g1\",\"publishedAt\":1789000000},\"packages\":{}}","handlingStrategy":"validation","validationCode":"if (!(\"meta\" in idx) || !(\"packages\" in idx)) throw new Error(\"index must contain both meta and packages\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate the index template includes both required top-level keys","Diff newly generated indexes against a schema checklist before publishing","Avoid manual edits to cached index files"],"tags":["bazaar","metadata","validation","missing-field"],"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"}