{"record":{"id":"2aae72b9fddf89c0","repo":"maotoumao/MusicFree","slug":"toast-failtoimportsheet","errorCode":null,"errorMessage":"toast.failToImportSheet","messagePattern":"toast\\.failToImportSheet","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/pages/setting/settingTypes/pluginSetting/components/pluginItem.tsx","lineNumber":175,"sourceCode":"                        Toast.success(t(\"toast.importing\"));\r\n                        closePanel();\r\n                        const result = await plugin.methods.importMusicSheet(\r\n                            text,\r\n                        );\r\n                        if (result && result.length > 0) {\r\n                            showDialog(\"SimpleDialog\", {\r\n                                title: t(\"pluginSetting.pluginItem.options.importDialogTitle\"),\r\n                                content: t(\"pluginSetting.pluginItem.options.importSheetDialogContent\", {\r\n                                    count: result.length,\r\n                                }),\r\n                                onOk() {\r\n                                    showPanel(\"AddToMusicSheet\", {\r\n                                        musicItem: result,\r\n                                    });\r\n                                },\r\n                            });\r\n                        } else {\r\n                            Toast.warn(t(\"toast.failToImportSheet\"));\r\n                        }\r\n                    },\r\n                });\r\n            },\r\n            show: !!plugin.supportedMethods.has(\"importMusicSheet\"),\r\n        },\r\n        {\r\n            title: t(\"pluginSetting.pluginItem.options.userVariables\"),\r\n            icon: \"code-bracket-square\",\r\n            onPress() {\r\n                if (Array.isArray(plugin.instance.userVariables)) {\r\n                    showPanel(\"SetUserVariables\", {\r\n                        async onOk(newValue, closePanel) {\r\n                            pluginManager.setUserVariables(plugin, newValue);\r\n                            Toast.success(t(\"toast.settingSuccess\"));\r\n                            closePanel();\r\n                        },\r\n                        variables: plugin.instance.userVariables,\r","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/maotoumao/MusicFree/blob/d118b18b3d0c904400f7eea7bf99c0ceec6c1aee/src/pages/setting/settingTypes/pluginSetting/components/pluginItem.tsx#L157-L193","documentation":"This warning toast is shown when importing a whole music sheet (playlist) via a plugin produces an empty result. The code awaits `plugin.methods.importMusicSheet(text)` and warns 'failToImportSheet' when the result is falsy or an empty array (`result && result.length > 0` fails). Like the single-item import, the await is not wrapped in try/catch, so only resolved-empty outcomes surface this message.","triggerScenarios":"Submitting the import-sheet panel with a playlist URL/code that the plugin's `importMusicSheet` resolves to null/undefined/[] — unsupported playlist host, private/deleted playlist, empty playlist, or internal plugin failure that it swallows and returns empty.","commonSituations":"Pasting a playlist link from a service the plugin doesn't cover; the playlist is private or requires login (expired cookies in plugin user variables); platform API changes breaking the plugin's sheet parser; network timeouts leading the plugin to return an empty array.","solutions":["Confirm the playlist is public and its URL/host matches what the plugin supports (check the panel's `hints.importMusicSheet`).","Retry when network is stable; transient failures inside the plugin often surface as empty results.","Update the plugin — sheet parsers frequently break when the source platform changes its API.","Configure valid credentials in the plugin's user variables if the playlist requires authentication."],"exampleFix":"// before\nconst result = await plugin.methods.importMusicSheet(text);\nif (result && result.length > 0) { ... } else {\n    Toast.warn(t(\"toast.failToImportSheet\"));\n}\n// after\nlet result;\ntry {\n    result = await plugin.methods.importMusicSheet(text);\n} catch (e: any) {\n    Toast.warn(e?.message ?? t(\"toast.failToImportSheet\"));\n    return;\n}\nif (Array.isArray(result) && result.length > 0) { ... } else {\n    Toast.warn(t(\"toast.failToImportSheet\"));\n}","handlingStrategy":"validation","validationCode":"const result = await plugin.methods.importMusicSheet(text);\nif (!Array.isArray(result) || result.length === 0) {\n    Toast.warn(t(\"toast.failToImportSheet\"));\n    return;\n}","typeGuard":"function isNonEmptyMusicSheet(x: unknown): x is IMusicSheetItem[] {\n    return Array.isArray(x) && x.length > 0 && x.every(it => !!it && typeof it === \"object\");\n}","tryCatchPattern":"try {\n    const result = await plugin.methods.importMusicSheet(text);\n    if (!isNonEmptyMusicSheet(result)) throw new Error(\"empty sheet\");\n    // proceed\n} catch (e: any) {\n    Toast.warn(e?.message ?? t(\"toast.failToImportSheet\"));\n}","preventionTips":["Verify the playlist is public and its URL matches the plugin's documented importMusicSheet hints.","Wrap plugin calls in try/catch — rejections currently crash past this toast path.","Refresh plugin credentials in user variables for private/authorized playlists.","Update the plugin when a source platform changes its playlist API."],"tags":["plugin","import","playlist","validation"],"backgroundTag":"plugin-import-returned-null","analyzedSha":"d118b18b3d0c904400f7eea7bf99c0ceec6c1aee","analyzedAt":"2026-08-30T11:49:12.932Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}