siyuan-note/siyuan · error

invalid bazaar index generation metadata

Error message

invalid bazaar index generation metadata

What it means

Beyond schema >= 2, the index meta must carry a non-empty generation string and a publishedAt timestamp >= 1. If either is missing or empty, the parser rejects the index because generation metadata is what the client uses to identify and cache index generations reliably.

Source

Thrown at kernel/bazaar/index.go:219

	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 {
					return nil, fmt.Errorf("invalid bazaar index package: %s", packageName)
				}
				if nil != pkg.Rating {

View on GitHub (pinned to 8641553a1f)

Solutions

  1. Fix the index publisher to include a non-empty generation identifier and a positive Unix publishedAt timestamp in meta
  2. Validate published index JSON against the expected meta shape before uploading (schema >= 2, generation non-empty, publishedAt >= 1)
  3. If you maintain a mirror, regenerate the meta block from the upstream current-format index
  4. Update test fixtures/mocks to include complete meta

Example fix

// before
{"meta": {"schema": 2}}
// after
{"meta": {"schema": 2, "generation": "gen-2026-09-11", "publishedAt": 1757548800}}
Defensive patterns

Strategy: validation

Validate before calling

// validate meta completeness before publishing
if strings.TrimSpace(meta.Generation) == "" || meta.PublishedAt < 1 {
    return errors.New("index meta needs non-empty generation and publishedAt >= 1")
}

Try / catch

if err != nil && strings.Contains(err.Error(), "invalid bazaar index generation metadata") {
    // serve cached snapshot; alert the index publisher
}

Prevention

When it happens

Trigger: parseBazaarIndex processes an index whose meta has schema >= 2 but meta.Generation is empty/whitespace or meta.PublishedAt is 0 or negative (typically because those fields were omitted in the published JSON).

Common situations: A bazaar publisher writing a new index format but forgetting the generation/publishedAt fields; hand-crafted or test index fixtures lacking meta fields; a template that initializes meta with zero values.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


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