siyuan-note/siyuan · error
invalid bazaar index packages
Error message
invalid bazaar index packages
What it means
For supported-schema indexes, the raw `packages` JSON must unmarshal into a non-nil map of package name to package entry. If json.Unmarshal leaves ret.packages nil (payload is the literal `null`) the parser rejects it. This is distinct from the raw-level null check, which only guards the top-level object.
Solutions
- Fix the index generator to always emit a JSON object (use {} when there are no packages)
- Re-fetch the index from the official endpoint
- Change the fixture to "packages": {}
Example fix
// before
{"meta":{"schema":2,"generation":"g1","publishedAt":1789000000},"packages":null}
// after
{"meta":{"schema":2,"generation":"g1","publishedAt":1789000000},"packages":{}} Defensive patterns
Strategy: validation
Validate before calling
if (idx.packages === null || idx.packages === undefined || typeof idx.packages !== "object") throw new Error("packages must be a JSON object, not null") Prevention
- Serialize packages with an always-initialized map so nil emits {}
- Guard index generation against unset package collections
- Test the zero-packages case in index builders
When it happens
Trigger: fetchBazaarIndexPath gets an index where "packages" is the JSON literal null rather than an object; a fixture with "packages": null.
Common situations: An index generator serialized a nil packages map, emitting `null`; template rendering with an unset variable produced null.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Field [ ] must not be empty
- invalid marketplace package manifest
- invalid null bazaar index
- invalid package name
- invalid rating distribution length for package
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/b5bcc235623a8982.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/bazaar/index.go:231
return nil, err
}
if 2 > ret.meta.Schema {
return nil, fmt.Errorf("invalid bazaar index schema: %d", ret.meta.Schema)
}
if "" == strings.TrimSpace(ret.meta.Generation) || 1 > ret.meta.PublishedAt {
return nil, errors.New("invalid bazaar index generation metadata")
}
if bazaarIndexSchema < ret.meta.Schema {
ret.meta.RatingsAvailable = false
} else {
if !hasPackages {
return nil, errors.New("incomplete bazaar index metadata")
}
if err = json.Unmarshal(packagesRaw, &ret.packages); nil != err {
return nil, err
}
if nil == ret.packages {
return nil, errors.New("invalid bazaar index packages")
}
for packageName, pkg := range ret.packages {
if !IsValidPackageName(packageName) || nil == pkg || !isValidBazaarRepo(pkg.Repo) || 0 > pkg.Downloads {
return nil, fmt.Errorf("invalid bazaar index package: %s", packageName)
}
if nil != pkg.Rating {
rating, valid := normalizePackageRating(pkg.Rating)
if !valid {
return nil, fmt.Errorf("invalid bazaar package rating: %s", packageName)
}
pkg.Rating = rating
}
}
}
} else if hasPackages {
return nil, errors.New("incomplete bazaar index metadata")
}
View on GitHub (pinned to 9f775e8a12)