siyuan-note/siyuan · error
invalid bazaar repository
Error message
invalid bazaar repository: %s
What it means
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.
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
Example fix
// before
{"siyuan-note/siyuan":{"downloads":100},"status":"ok"}
// after
{"siyuan-note/siyuan":{"downloads":100}} Defensive patterns
Strategy: validation
Validate before calling
for (const key of Object.keys(idx)) {
if (key !== "meta" && key !== "packages" && !/^[^/]+\/[^/]+$/.test(key)) throw new Error(`unexpected top-level key: ${key}`)
} Prevention
- 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
When it happens
Trigger: 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").
Common situations: 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.
Related errors
- invalid bazaar downloads
- Field [ ] must not be empty
- incomplete bazaar index metadata
- invalid bazaar index generation metadata
- invalid bazaar index package
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/e38e949cda7292a0.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/bazaar/index.go:257
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")
}
if !hasMeta || 2 == ret.meta.Schema || bazaarIndexSchema < ret.meta.Schema {
for rawRepo, rawStats := range raw {
if "meta" == rawRepo || "packages" == rawRepo {
continue
}
repo, valid := normalizeLegacyBazaarRepo(rawRepo)
if !valid {
return nil, fmt.Errorf("invalid bazaar repository: %s", rawRepo)
}
stats := &bazaarStats{}
if err = json.Unmarshal(rawStats, stats); nil != err {
return nil, err
}
if 0 > stats.Downloads {
return nil, fmt.Errorf("invalid bazaar downloads: %s", rawRepo)
}
if current := ret.legacyStats[repo]; nil != current {
if stats.Downloads > int(^uint(0)>>1)-current.Downloads {
return nil, fmt.Errorf("bazaar downloads overflow: %s", repo)
}
current.Downloads += stats.Downloads
continue
}
ret.legacyStats[repo] = stats
}
}View on GitHub (pinned to 9f775e8a12)