siyuan-note/siyuan · error

invalid bazaar index schema: %d

Error message

invalid bazaar index schema: %d

What it means

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.

Source

Thrown at kernel/bazaar/index.go:216

	if err = json.Unmarshal(data, &raw); nil != err {
		return nil, err
	}
	if nil == raw {
		return nil, errors.New("invalid null bazaar index")
	}
	ret = &bazaarIndexSnapshot{
		packages:    map[string]*bazaarIndexPackage{},
		legacyStats: map[string]*bazaarStats{},
	}

	metaRaw, hasMeta := raw["meta"]
	packagesRaw, hasPackages := raw["packages"]
	if hasMeta {
		if err = json.Unmarshal(metaRaw, &ret.meta); nil != err {
			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 {

View on GitHub (pinned to 8641553a1f)

Solutions

  1. Update the bazaar server to publish index schema >= 2 with a correct meta block
  2. If you run a local mirror/mock of the index, regenerate it with the current schema-2 format (meta with schema, generation, publishedAt)
  3. Check whether a broken deploy rolled back the index format and restore the current publisher
  4. 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

Example fix

// server-side index meta
// before
{"meta": {"schema": 1, ...}}
// after
{"meta": {"schema": 2, "generation": "2026-09-11T00:00:00Z", "publishedAt": 1757548800, ...}}
Defensive patterns

Strategy: validation

Validate before calling

// validate the published index meta before upload
var idx struct{ Meta struct{ Schema int `json:"schema"` } `json:"meta"` }
if json.Unmarshal(body, &idx) != nil || idx.Meta.Schema < 2 {
    return errors.New("index schema must be >= 2")
}

Try / catch

if err != nil && strings.Contains(err.Error(), "invalid bazaar index schema") {
    // reject the snapshot, keep serving the cached one; fix the publisher
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

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


AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11). Data as JSON: /api/errors/5563f41878fb4258. Report an issue: GitHub.