{"record":{"id":"7bff72806ebf204b","repo":"siyuan-note/siyuan","slug":"bazaar-hash-not-available","errorCode":null,"errorMessage":"bazaar hash not available","messagePattern":"bazaar hash not available","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/bazaar/stage.go","lineNumber":167,"sourceCode":"// getStageIndexFromCache 仅从缓存获取 stage 索引，无缓存时返回 nil（读前根据 util 已同步的 bazaar hash 视情况清理缓存）\nfunc getStageIndexFromCache(ctx context.Context, pkgType string) *StageIndex {\n\tapplyRhyBazaarHash(ctx)\n\tbazaarMemMu.RLock()\n\tdefer bazaarMemMu.RUnlock()\n\treturn stageIndexCache[pkgType]\n}\n\n// getStageIndex 获取 stage 索引\nfunc getStageIndex(ctx context.Context, pkgType string) (ret *StageIndex, err error) {\n\tif cached := getStageIndexFromCache(ctx, pkgType); nil != cached {\n\t\tret = cached\n\t\treturn\n\t}\n\n\tbazaarHash := util.GetRhyBazaarHash(ctx)\n\tif \"\" == bazaarHash {\n\t\tlogging.LogErrorf(\"bazaar hash unavailable (rhy missing or invalid bazaar field)\")\n\t\terr = errors.New(\"bazaar hash not available\")\n\t\treturn\n\t}\n\tret = &StageIndex{}\n\trequest := httpclient.NewBrowserRequest()\n\tu := util.BazaarOSSServer + \"/bazaar@\" + bazaarHash + \"/stage/\" + pkgType + \".json\" // pkgType 单词为复数形式\n\tresp, reqErr := request.SetContext(ctx).SetSuccessResult(ret).Get(u)\n\tif nil != reqErr {\n\t\tlogging.LogErrorf(\"get community stage index [%s] failed: %s\", u, reqErr)\n\t\terr = reqErr\n\t\treturn\n\t}\n\tif 200 != resp.StatusCode {\n\t\tlogging.LogErrorf(\"get community stage index [%s] failed: %d\", u, resp.StatusCode)\n\t\terr = errors.New(\"get stage index failed\")\n\t\treturn\n\t}\n\n\tfor _, repo := range ret.Repos {","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/bazaar/stage.go#L149-L185","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure the kernel has outbound network access to the rhy/community endpoint on first call","Retry after connectivity is restored — GetRhyBazaarHash lazily fetches and caches","Check kernel logs for the accompanying 'bazaar hash unavailable (rhy missing or invalid bazaar field)' message and resolve the underlying rhy fetch failure"],"exampleFix":"// before: calling stage index without ensuring rhy is populated\nidx, err := getStageIndex(ctx, pkgType)\n\n// after: warm up rhy first and surface a clearer error\nif util.GetRhyBazaarHash(ctx) == \"\" {\n    return nil, errors.New(\"community index unavailable; check network and retry\")\n}\nidx, err := getStageIndex(ctx, pkgType)","handlingStrategy":"try-catch","validationCode":"// Warm up rhy and fail fast with a clearer message before calling getStageIndex\nif util.GetRhyBazaarHash(ctx) == \"\" {\n    return nil, errors.New(\"community index unavailable; check network and retry\")\n}","typeGuard":null,"tryCatchPattern":"idx, err := getStageIndex(ctx, pkgType)\nif err != nil {\n    if strings.Contains(err.Error(), \"bazaar hash not available\") {\n        // transient: rhy not fetched yet; user should retry once online\n        return nil, fmt.Errorf(\"community index unavailable, retry later: %w\", err)\n    }\n    return nil, err\n}","preventionTips":["Ensure outbound network to the rhy endpoint on first boot","Surface rhy fetch failures to the user so they can fix connectivity","Retry stage-index calls after restoring network rather than disabling the feature"],"tags":["bazaar","network","rhy","stage-index","marketplace"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}