{"record":{"id":"c7d7ad740e1fa49b","repo":"maotoumao/MusicFree","slug":"error-c7d7ad","errorCode":null,"errorMessage":"搜索结果为空","messagePattern":"搜索结果为空","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"src/pages/searchPage/hooks/useSearch.ts","lineNumber":124,"sourceCode":"                    );\n                    // !! jscore的promise有问题，改成hermes就好了，可能和JIT有关，不知道。\n                    const result = await plugin?.methods?.search?.(\n                        query,\n                        page,\n                        searchType,\n                    );\n                    /** 如果搜索结果不是本次结果 */\n                    if (currentQueryRef.current !== query) {\n                        return;\n                    }\n                    /** 切换到结果页 */\n                    const currentPageStatus =\n                        getDefaultStore().get(pageStatusAtom);\n                    if (currentPageStatus !== PageStatus.EDITING) {\n                        setPageStatus(PageStatus.RESULT);\n                    }\n                    if (!result) {\n                        throw new Error(\"搜索结果为空\");\n                    }\n                    setSearchResults(\n                        produce(draft => {\n                            const prevMediaResult = draft[searchType];\n                            const prevPluginResult: any = prevMediaResult[\n                                _hash\n                            ] ?? {\n                                data: [],\n                            };\n                            const currResult = result.data ?? [];\n\n                            prevMediaResult[_hash] = {\n                                state:\n                                    result?.isEnd === false &&\n                                        result?.data?.length\n                                        ? RequestStateCode.PARTLY_DONE\n                                        : RequestStateCode.FINISHED,\n                                query,","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/maotoumao/MusicFree/blob/d118b18b3d0c904400f7eea7bf99c0ceec6c1aee/src/pages/searchPage/hooks/useSearch.ts#L106-L142","documentation":"useSearch throws Error('搜索结果为空') (\"search result is empty\") when the search hook receives a falsy result back from the plugin search call. It guards the state update so empty/failed plugin responses never overwrite existing results. The page status is set to RESULT only when not in EDITING mode.","triggerScenarios":"Invoking the search function of useSearch where the plugin's search() resolves to undefined/null/empty — e.g. plugin returns no data, keyword yields zero results with no result envelope, or the plugin throws and is caught upstream returning nothing.","commonSituations":"Searching with a plugin whose remote API changed or is down; entering keywords that match nothing and the plugin returns null instead of an empty list; stale plugin after a music-site redesign; searching while offline.","solutions":["Check network connectivity and retry the search.","Update the search plugin for the selected platform so its search returns a valid result object.","In the plugin, return an empty result structure ({data: [], ...}) instead of null/undefined for zero-hit searches.","Wrap the search call so a null result is shown as 'no results' UI rather than propagating an exception."],"exampleFix":"// before\nconst result = await plugin.methods.search(keyword, page, type);\n// after\nconst result = (await plugin.methods.search(keyword, page, type)) ?? { isEnd: true, data: [] };","handlingStrategy":"try-catch","validationCode":"if (!keyword?.trim()) return; // don't even call search\nconst plugin = pluginManagerService.getBySearchType(searchType);\nif (!plugin?.methods?.search) { setNoResults(); return; }","typeGuard":"function isSearchResult(r: unknown): boolean {\n  return !!r && typeof r === 'object' && Array.isArray((r as any).data);\n}","tryCatchPattern":"try {\n  await search(keyword);\n} catch (e) {\n  if (e?.message === '搜索结果为空') {\n    setPageStatus(PageStatus.RESULT); // show empty state, keep old data\n  } else {\n    Toast.warn(e?.message ?? String(e));\n  }\n}","preventionTips":["Treat a falsy plugin search response as 'no results', not an exception, at the plugin level.","Update search plugins when a platform's API changes.","Check connectivity before searching and show a distinct offline state.","Guard the search call when the page is in EDITING mode."],"tags":["search","plugin","empty-result","ui-state"],"backgroundTag":"empty-search-result","analyzedSha":"d118b18b3d0c904400f7eea7bf99c0ceec6c1aee","analyzedAt":"2026-08-30T11:49:12.932Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}