siyuan-note/siyuan · error

invalid bazaar repository: %s

Error message

invalid bazaar repository: %s

What it means

When parsing the legacy portion of a bazaar index, every top-level key other than 'meta' and 'packages' must be a valid repository identifier (an 'owner/repo' GitHub path, optionally with a https://github.com/ prefix, case-normalized). parseBazaarIndex throws this error when normalizeLegacyBazaarRepo rejects a key.

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 8641553a1f)

Solutions

  1. Inspect the index JSON keys and fix/replace the malformed repository key with a valid 'owner/repo' form
  2. Re-fetch the index from the official bazaar stat server to rule out a stale/corrupted cache
  3. If running a mirror, emit keys as 'owner/repo' (an optional 'https://github.com/' prefix is stripped automatically)
  4. Check isValidBazaarRepo in kernel/bazaar for the exact accepted format and normalize your keys accordingly

Example fix

// before (index JSON)
{"my-plugin": {"downloads": 5}}
// after
{"https://github.com/siyuan-note/my-plugin": {"downloads": 5}}
Defensive patterns

Strategy: validation

Validate before calling

for key := range indexObj {
	if key == "meta" || key == "packages" { continue }
	if _, ok := normalizeLegacyBazaarRepo(key); !ok {
		return fmt.Errorf("bad repo key: %s", key)
	}
}

Type guard

func isValidRepoKey(key string) bool {
	_, ok := normalizeLegacyBazaarRepo(key) // accepts 'owner/repo' with optional https://github.com/ prefix
	return ok
}

Try / catch

snapshot, err := parseBazaarIndex(data)
if err != nil {
	if strings.HasPrefix(err.Error(), "invalid bazaar repository:") {
		log.Errorf("index contains malformed repo key; refetch from official server")
	}
	return err
}

Prevention

When it happens

Trigger: A legacy-format index JSON contains a top-level key like 'foo', 'https://github.com/', 'owner/repo/extra', or an empty string instead of a valid owner/repo repo key; the loop over raw map entries then fails validation.

Common situations: A corrupted or tampered index from a CDN; a custom index mirror emitting stats keyed by package name or URL variants the validator rejects; trailing slashes or uppercase/special characters in repo keys not accepted by isValidBazaarRepo.

Understand the failure class

Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.

Related errors


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