{"record":{"id":"f236e47313f902f1","repo":"siyuan-note/siyuan","slug":"stage-index-is-unavailable","errorCode":null,"errorMessage":"stage index is unavailable","messagePattern":"stage index is unavailable","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/bazaar/stage.go","lineNumber":280,"sourceCode":"\t\t}\n\t})\n\treturn stageIndex.reposByURL[url]\n}\n\n// HasBazaarPackage 判断指定名称是否存在于官方集市 Stage 索引中。\nfunc HasBazaarPackage(ctx context.Context, pkgType, packageName string) (bool, error) {\n\tpackageNames, err := GetExistingBazaarPackageNames(ctx, pkgType, []string{packageName})\n\treturn 0 < len(packageNames), err\n}\n\n// GetExistingBazaarPackageNames 筛选存在于官方集市 Stage 索引中的包名。\nfunc GetExistingBazaarPackageNames(ctx context.Context, pkgType string, packageNames []string) ([]string, error) {\n\tstageIndex, err := getStageIndex(ctx, pkgType)\n\tif nil != err {\n\t\treturn nil, err\n\t}\n\tif nil == stageIndex {\n\t\treturn nil, errors.New(\"stage index is unavailable\")\n\t}\n\tofficial := make(map[string]bool, len(stageIndex.Repos))\n\tfor _, repo := range stageIndex.Repos {\n\t\tif nil != repo && nil != repo.Package {\n\t\t\tofficial[repo.Package.Name] = true\n\t\t}\n\t}\n\tret := make([]string, 0, len(packageNames))\n\tfor _, packageName := range packageNames {\n\t\tif official[packageName] {\n\t\t\tret = append(ret, packageName)\n\t\t}\n\t}\n\treturn ret, nil\n}\n\n// bazaarStats 集市包统计信息\ntype bazaarStats struct {","sourceCodeStart":262,"sourceCodeEnd":298,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/bazaar/stage.go#L262-L298","documentation":"GetExistingBazaarPackageNames returns this error when getStageIndex succeeded (nil error) but returned a nil stage index. It is an internal defensive check ensuring callers never receive a nil index without an error.","triggerScenarios":"HasBazaarPackage calls GetExistingBazaarPackageNames and getStageIndex returns (nil, nil) — practically a rare invariant violation, e.g. an unexpected code path or future refactor where an early return yields a nil result without setting err.","commonSituations":"Mostly hit during development or refactoring of kernel/bazaar when a success path accidentally skips index population; end users should normally see 461/462 instead.","solutions":["Check the earlier logged error from getStageIndex — fix the underlying index-fetch failure (see errors 461/462).","If developing: audit getStageIndex so every success path returns a non-nil *StageIndex.","Retry the marketplace operation after network issues are resolved."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"if stageIndex == nil {\n    return errors.New(\"stage index is unavailable\")\n}","tryCatchPattern":"names, err := GetExistingBazaarPackageNames(ctx, pkgType, pkgs)\nif err != nil {\n    log.Printf(\"cannot check existing packages: %v\", err)\n    return err\n}","preventionTips":["Always check err before dereferencing results from bazaar index helpers.","If hacking on kernel/bazaar, keep every success path in getStageIndex returning a non-nil index."],"tags":["bazaar","invariant","null"],"backgroundTag":"internal-invariant-violation","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"}