{"record":{"id":"bcaf251b445c8aae","repo":"siyuan-note/siyuan","slug":"get-stage-index-failed","errorCode":null,"errorMessage":"get stage index failed","messagePattern":"get stage index failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/bazaar/stage.go","lineNumber":181,"sourceCode":"\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 {\n\t\tunescapePackageDisplayStrings(repo.Package)\n\t}\n\n\tbazaarMemMu.Lock()\n\tstageIndexCache[pkgType] = ret\n\tbazaarMemMu.Unlock()\n\treturn\n}\n\n// getStageRepoByURL 根据 pkgType 与 url（owner/repo@hash）获取 StageRepo\nfunc getStageRepoByURL(ctx context.Context, pkgType, url string) *StageRepo {\n\tstageIndex, _ := getStageIndex(ctx, pkgType)\n\tif nil == stageIndex {\n\t\treturn nil","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/251596fc0de2f9528c00c224252fd073a99973f4/kernel/bazaar/stage.go#L163-L199","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// before: treating any non-200 the same\nif 200 != resp.StatusCode {\n    err = errors.New(\"get stage index failed\")\n}\n\n// after: include status and URL for diagnosability\nif 200 != resp.StatusCode {\n    err = fmt.Errorf(\"get stage index failed: %s returned %d\", u, resp.StatusCode)\n}","handlingStrategy":"retry","validationCode":"// Sanity-check pkgType against known values before constructing the URL\nvar validPkgTypes = map[string]bool{\"plugins\":true,\"themes\":true,\"icons\":true,\"templates\":true,\"widgets\":true}\nif !validPkgTypes[pkgType] { return nil, fmt.Errorf(\"unknown pkgType %q\", pkgType) }","typeGuard":null,"tryCatchPattern":"idx, err := getStageIndex(ctx, pkgType)\nif err != nil {\n    // log already includes status code + URL; retry once for transient OSS 5xx\n    return nil, err\n}","preventionTips":["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"],"tags":["bazaar","network","stage-index","http","marketplace"],"backgroundTag":null,"analyzedSha":"251596fc0de2f9528c00c224252fd073a99973f4","analyzedAt":"2026-08-12T21:18:37.123Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}