siyuan-note/siyuan · error
get stage index failed
Error message
get stage index failed
What it means
The HTTP GET to the community stage index (util.BazaarOSSServer + /bazaar@<hash>/stage/<pkgType>.json) returned a non-200 status. Thrown at kernel/bazaar/stage.go:179-181 after the request itself succeeded (no transport error). The status code is logged but not surfaced in the error string.
Source
Thrown at kernel/bazaar/stage.go:181
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 {
unescapePackageDisplayStrings(repo.Package)
}
bazaarMemMu.Lock()
stageIndexCache[pkgType] = ret
bazaarMemMu.Unlock()
return
}
// getStageRepoByURL 根据 pkgType 与 url(owner/repo@hash)获取 StageRepo
func getStageRepoByURL(ctx context.Context, pkgType, url string) *StageRepo {
stageIndex, _ := getStageIndex(ctx, pkgType)
if nil == stageIndex {
return nilView on GitHub (pinned to 251596fc0d)
Solutions
- Check the kernel log line 'get community stage index [<url>] failed: <code>' for the exact status and URL
- Refresh the rhy/bazaar hash (restart kernel or wait for rhy refresh) in case the hash rotated
- Retry transient 5xx responses; if persistent, verify BazaarOSSServer reachability
Example fix
// before: treating any non-200 the same
if 200 != resp.StatusCode {
err = errors.New("get stage index failed")
}
// after: include status and URL for diagnosability
if 200 != resp.StatusCode {
err = fmt.Errorf("get stage index failed: %s returned %d", u, resp.StatusCode)
} Defensive patterns
Strategy: retry
Validate before calling
// Sanity-check pkgType against known values before constructing the URL
var validPkgTypes = map[string]bool{"plugins":true,"themes":true,"icons":true,"templates":true,"widgets":true}
if !validPkgTypes[pkgType] { return nil, fmt.Errorf("unknown pkgType %q", pkgType) } Try / catch
idx, err := getStageIndex(ctx, pkgType)
if err != nil {
// log already includes status code + URL; retry once for transient OSS 5xx
return nil, err
} Prevention
- Log the URL and status code (already done) to distinguish 404 from 5xx
- Retry transient 5xx with backoff; treat persistent 404 as a stale hash
- Refresh the bazaar hash (restart/re-fetch rhy) when the hash rotates
When it happens
Trigger: getStageIndex constructed the OSS URL with a bazaar hash and pkgType and the OSS server responded with anything other than 200 (e.g. 404 for an unknown hash/pkgType, 5xx for OSS outage).
Common situations: Stale or invalid bazaar hash pointing at a non-existent index path; OSS deployment/CDN problem returning 5xx; pkgType value that has no stage index file; hash rotation mid-session leaving the old URL dead.
Related errors
- bazaar hash not available
- bazaar is offline
- get bazaar package failed, please check your network
- get bazaar package failed: %s
- download custom emoji failed with status %d
AI-assisted analysis of siyuan-note/siyuan@251596fc0d (2026-08-12).
Data as JSON: /api/errors/bcaf251b445c8aae.
Report an issue: GitHub.