{"record":{"id":"9a7744e380d677d5","repo":"siyuan-note/siyuan","slug":"get-current-bazaar-index-failed-w-get-legacy-ba","errorCode":null,"errorMessage":"get current bazaar index failed: %w; get legacy bazaar index failed: %v","messagePattern":"get current bazaar index failed: %w; get legacy bazaar index failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/bazaar/index.go","lineNumber":177,"sourceCode":"}\n\nfunc snapshotBazaarIndex(now time.Time) (snapshot *bazaarIndexSnapshot, fresh, canRetry bool) {\n\tbazaarIndexState.mu.RLock()\n\tdefer bazaarIndexState.mu.RUnlock()\n\tsnapshot = bazaarIndexState.snapshot\n\tfresh = nil != snapshot && now.Before(bazaarIndexState.expiresAt)\n\tcanRetry = bazaarIndexState.retryAt.IsZero() || !now.Before(bazaarIndexState.retryAt)\n\treturn\n}\n\nfunc fetchBazaarIndex(ctx context.Context) (ret *bazaarIndexSnapshot, err error) {\n\tret, err = fetchBazaarIndexPath(ctx, bazaarIndexPath)\n\tif nil == err {\n\t\treturn\n\t}\n\tlegacy, legacyErr := fetchBazaarIndexPath(ctx, bazaarLegacyIndexPath)\n\tif nil != legacyErr {\n\t\treturn nil, fmt.Errorf(\"get current bazaar index failed: %w; get legacy bazaar index failed: %v\", err, legacyErr)\n\t}\n\treturn legacy, nil\n}\n\nfunc fetchBazaarIndexPath(ctx context.Context, indexPath string) (ret *bazaarIndexSnapshot, err error) {\n\ttimeBucket := bazaarIndexNow().Unix() / int64(bazaarIndexCDNBucket/time.Second)\n\tu := fmt.Sprintf(\"%s%s?t=%d\", bazaarIndexStatServer, indexPath, timeBucket)\n\tbuf := &bytes.Buffer{}\n\tresp, err := httpclient.NewBrowserRequest().SetRetryCount(0).SetContext(ctx).SetOutput(buf).Get(u)\n\tif nil != err {\n\t\treturn nil, err\n\t}\n\tif 200 != resp.StatusCode {\n\t\treturn nil, fmt.Errorf(\"unexpected status code: %d\", resp.StatusCode)\n\t}\n\treturn parseBazaarIndex(buf.Bytes())\n}\n","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/bazaar/index.go#L159-L195","documentation":"fetchBazaarIndex tries the current CDN bucket path for the bazaar package index; if that fails it falls back to the legacy index path. Only when BOTH the current and legacy index fetches fail does it wrap both failures into this combined error. It reports two underlying causes: the current-index error (%w) and the legacy-index error (%v).","triggerScenarios":"Any marketplace index load (plugins/themes/icons/templates/widgets listing) when both https CDN bucket path and legacy path fail: DNS failure, blocked hosts, TLS errors, non-200 responses from both endpoints, or request context cancellation.","commonSituations":"Fully offline machines; firewalls blocking all bazaar hosts; CDN misconfiguration or both endpoints returning 5xx; clock skew is unrelated here but an expired/changed CDN path plus a removed legacy path yields this.","solutions":["Read the two embedded causes: fix the specific network problem reported by the current-index error first","Restore connectivity / configure the proxy so the CDN bucket URL is reachable","Retry later if both endpoints are down at the CDN side","Check kernel logs for the underlying fetch errors (DNS vs TLS vs status code) to target the fix"],"exampleFix":"// before: ignoring the wrapped causes\nlog.Println(err)\n// after: unwrap the current-index cause\nvar cur error\nif e := errors.Unwrap(err); e != nil { cur = e }\nlog.Printf(\"bazaar index unreachable, current cause: %v\", cur)","handlingStrategy":"retry","validationCode":"// check basic reachability of the bazaar host before calling the API\nconst online = await fetch(\"https://bazaar.si-yuan.com/index.json\", {method: \"HEAD\"}).then(r => r.ok).catch(() => false);\nif (!online) console.warn(\"bazaar unreachable; expect combined index error\");","typeGuard":null,"tryCatchPattern":"try { await listBazaar() } catch (e) { if (String(e).includes(\"get current bazaar index failed\")) { await delay(2000); retry(maxAttempts = 3); } }","preventionTips":["Read both embedded causes to identify which endpoint path failed","Retry with backoff since both CDN paths can fail transiently","Verify proxy/DNS when errors persist","Keep the kernel updated for current CDN URL schemes"],"tags":["network","bazaar","cdn","index-fetch"],"backgroundTag":"network-request-failed","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}