siyuan-note/siyuan · error

bazaar hash not available

Error message

bazaar hash not available

What it means

util.GetRhyBazaarHash returned an empty string, so getStageIndex cannot construct the community-stage-index URL. Thrown at kernel/bazaar/stage.go:164-167. The bazaar hash comes from the rhy (community repository index) result's 'bazaar' field; when rhy is missing, failed to fetch, or its bazaar field is empty/non-string, the hash stays empty.

Source

Thrown at kernel/bazaar/stage.go:167

// getStageIndexFromCache 仅从缓存获取 stage 索引,无缓存时返回 nil(读前根据 util 已同步的 bazaar hash 视情况清理缓存)
func getStageIndexFromCache(ctx context.Context, pkgType string) *StageIndex {
	applyRhyBazaarHash(ctx)
	bazaarMemMu.RLock()
	defer bazaarMemMu.RUnlock()
	return stageIndexCache[pkgType]
}

// getStageIndex 获取 stage 索引
func getStageIndex(ctx context.Context, pkgType string) (ret *StageIndex, err error) {
	if cached := getStageIndexFromCache(ctx, pkgType); nil != cached {
		ret = cached
		return
	}

	bazaarHash := util.GetRhyBazaarHash(ctx)
	if "" == bazaarHash {
		logging.LogErrorf("bazaar hash unavailable (rhy missing or invalid bazaar field)")
		err = errors.New("bazaar hash not available")
		return
	}
	ret = &StageIndex{}
	request := httpclient.NewBrowserRequest()
	u := util.BazaarOSSServer + "/bazaar@" + bazaarHash + "/stage/" + pkgType + ".json" // pkgType 单词为复数形式
	resp, reqErr := request.SetContext(ctx).SetSuccessResult(ret).Get(u)
	if nil != reqErr {
		logging.LogErrorf("get community stage index [%s] failed: %s", u, reqErr)
		err = reqErr
		return
	}
	if 200 != resp.StatusCode {
		logging.LogErrorf("get community stage index [%s] failed: %d", u, resp.StatusCode)
		err = errors.New("get stage index failed")
		return
	}

	for _, repo := range ret.Repos {

View on GitHub (pinned to 251596fc0d)

Solutions

  1. Ensure the kernel has outbound network access to the rhy/community endpoint on first call
  2. Retry after connectivity is restored — GetRhyBazaarHash lazily fetches and caches
  3. Check kernel logs for the accompanying 'bazaar hash unavailable (rhy missing or invalid bazaar field)' message and resolve the underlying rhy fetch failure

Example fix

// before: calling stage index without ensuring rhy is populated
idx, err := getStageIndex(ctx, pkgType)

// after: warm up rhy first and surface a clearer error
if util.GetRhyBazaarHash(ctx) == "" {
    return nil, errors.New("community index unavailable; check network and retry")
}
idx, err := getStageIndex(ctx, pkgType)
Defensive patterns

Strategy: try-catch

Validate before calling

// Warm up rhy and fail fast with a clearer message before calling getStageIndex
if util.GetRhyBazaarHash(ctx) == "" {
    return nil, errors.New("community index unavailable; check network and retry")
}

Try / catch

idx, err := getStageIndex(ctx, pkgType)
if err != nil {
    if strings.Contains(err.Error(), "bazaar hash not available") {
        // transient: rhy not fetched yet; user should retry once online
        return nil, fmt.Errorf("community index unavailable, retry later: %w", err)
    }
    return nil, err
}

Prevention

When it happens

Trigger: Any code path that calls getStageIndex (community package browsing, install-from-repo, stage lookups) on a kernel where util.GetRhyBazaarHash(ctx) returns "". This happens before any network call to the OSS server.

Common situations: First boot or offline kernel where rhy has not been fetched yet and the fetch fails; network blocked to the rhy endpoint; rhy returned but its bazaar field is missing or empty (corrupt index); a proxy/firewall dropping the rhy request.

Related errors


AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12). Data as JSON: /api/errors/7bff72806ebf204b. Report an issue: GitHub.