siyuan-note/siyuan · error
get current bazaar index failed: %w; get legacy bazaar index
Error message
get current bazaar index failed: %w; get legacy bazaar index failed: %v
What it means
fetchBazaarIndex tries the current CDN bazaar index path first and falls back to the legacy path. This error wraps both failures: the primary fetch error (%w) and the legacy fetch error (%v). It means neither the current nor the legacy index endpoint could be reached or parsed, so no bazaar index snapshot is available.
Source
Thrown at kernel/bazaar/index.go:177
}
func snapshotBazaarIndex(now time.Time) (snapshot *bazaarIndexSnapshot, fresh, canRetry bool) {
bazaarIndexState.mu.RLock()
defer bazaarIndexState.mu.RUnlock()
snapshot = bazaarIndexState.snapshot
fresh = nil != snapshot && now.Before(bazaarIndexState.expiresAt)
canRetry = bazaarIndexState.retryAt.IsZero() || !now.Before(bazaarIndexState.retryAt)
return
}
func fetchBazaarIndex(ctx context.Context) (ret *bazaarIndexSnapshot, err error) {
ret, err = fetchBazaarIndexPath(ctx, bazaarIndexPath)
if nil == err {
return
}
legacy, legacyErr := fetchBazaarIndexPath(ctx, bazaarLegacyIndexPath)
if nil != legacyErr {
return nil, fmt.Errorf("get current bazaar index failed: %w; get legacy bazaar index failed: %v", err, legacyErr)
}
return legacy, nil
}
func fetchBazaarIndexPath(ctx context.Context, indexPath string) (ret *bazaarIndexSnapshot, err error) {
timeBucket := bazaarIndexNow().Unix() / int64(bazaarIndexCDNBucket/time.Second)
u := fmt.Sprintf("%s%s?t=%d", bazaarIndexStatServer, indexPath, timeBucket)
buf := &bytes.Buffer{}
resp, err := httpclient.NewBrowserRequest().SetRetryCount(0).SetContext(ctx).SetOutput(buf).Get(u)
if nil != err {
return nil, err
}
if 200 != resp.StatusCode {
return nil, fmt.Errorf("unexpected status code: %d", resp.StatusCode)
}
return parseBazaarIndex(buf.Bytes())
}
View on GitHub (pinned to 8641553a1f)
Solutions
- Fix the underlying connectivity problem so at least one of the two index URLs is reachable
- Check whether the bazaar server is publishing a valid index; a single fixed server-side index resolves this client-side
- Rely on the cached snapshot if one exists (snapshotBazaarIndex serves stale data while refresh fails) and retry after network recovery
- Inspect the wrapped errors (%w primary and %v legacy) separately — the primary error usually names the real cause (status code, timeout, parse failure)
Defensive patterns
Strategy: retry
Try / catch
snapshot, err := fetchBazaarIndex(ctx)
if err != nil {
var netErr net.Error
if errors.As(err, &netErr) || strings.Contains(err.Error(), "unexpected status code") {
// schedule a retry with backoff; serve stale cached snapshot meanwhile
}
} Prevention
- Serve the last cached snapshot while refreshes fail instead of erroring to users
- Retry with exponential backoff — CDN outages are usually transient
- Alert on server-side index publication failures, since both paths failing usually means the publisher is broken
When it happens
Trigger: The background index refresh calls fetchBazaarIndex and fetchBazaarIndexPath fails for both bazaarIndexPath and bazaarLegacyIndexPath — e.g. network is down, both CDN URLs return non-200 (see index.go:191), or both payloads fail parseBazaarIndex validation.
Common situations: Total loss of internet connectivity; bazaar CDN outage affecting both index URLs; a server-side change publishing invalid index JSON to both paths; DNS or proxy blocking the bazaar host; unit tests forcing both paths to fail.
Related errors
- bazaar is offline
- unexpected status code: %d
- get bazaar package failed, please check your network
- Conf.Language(46)
- get bazaar package failed: %s
AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11).
Data as JSON: /api/errors/9a7744e380d677d5.
Report an issue: GitHub.