{"record":{"id":"ee1d53ab88b278ff","repo":"maotoumao/MusicFree","slug":"toast-failtoimportmusic","errorCode":null,"errorMessage":"toast.failToImportMusic","messagePattern":"toast\\.failToImportMusic","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/pages/setting/settingTypes/pluginSetting/components/pluginItem.tsx","lineNumber":140,"sourceCode":"                            text,\r\n                        );\r\n                        if (result) {\r\n                            showDialog(\"SimpleDialog\", {\r\n                                title: t(\"pluginSetting.pluginItem.options.importDialogTitle\"),\r\n                                content: t(\"pluginSetting.pluginItem.options.importMusicDialogContent\", {\r\n                                    name: result.title,\r\n                                }),\r\n                                onOk() {\r\n                                    showPanel(\"AddToMusicSheet\", {\r\n                                        musicItem: result,\r\n                                        newSheetDefaultName: t(\"pluginSetting.pluginItem.options.importMusicToSheetName\", {\r\n                                            name: plugin.name,\r\n                                        }),\r\n                                    });\r\n                                },\r\n                            });\r\n                        } else {\r\n                            Toast.warn(t(\"toast.failToImportMusic\"));\r\n                        }\r\n                    },\r\n                });\r\n            },\r\n            show: !!plugin.supportedMethods.has(\"importMusicItem\"),\r\n        },\r\n        {\r\n            title: t(\"pluginSetting.pluginItem.options.importSheet\"),\r\n            icon: \"arrow-right-end-on-rectangle\",\r\n            onPress() {\r\n                showPanel(\"SimpleInput\", {\r\n                    title: t(\"pluginSetting.pluginItem.options.importSheet\"),\r\n                    placeholder: t(\"pluginSetting.pluginItem.options.importSheetPlaceHolder\"),\r\n                    hints: plugin.instance.hints?.importMusicSheet,\r\n                    maxLength: 1000,\r\n                    async onOk(text, closePanel) {\r\n                        Toast.success(t(\"toast.importing\"));\r\n                        closePanel();\r","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/maotoumao/MusicFree/blob/d118b18b3d0c904400f7eea7bf99c0ceec6c1aee/src/pages/setting/settingTypes/pluginSetting/components/pluginItem.tsx#L122-L158","documentation":"This warning toast is shown when importing a single music item via a plugin yields no usable result. After the user enters a URL/text in the SimpleInput panel, the code awaits `plugin.methods.importMusicItem(text)`; if the resolved value is falsy (null/undefined/empty), it warns 'failToImportMusic'. The plugin itself is expected to resolve a shared link into an IMusicItem; a falsy return means the plugin could not resolve it.","triggerScenarios":"Submitting the import-music panel with text that the plugin's `importMusicItem` cannot resolve: an unsupported URL/host, a private or deleted track, an invalid share-code format, or the plugin returning null on any internal error. Also note any rejection here is unhandled (no try/catch around the await), so only falsy results reach this toast.","commonSituations":"Pasting a link from a music service the plugin doesn't support; sharing an expired or region-locked link; network failure inside the plugin causing it to return null; plugin's user variables (e.g. cookies/tokens) missing or expired; typos in a manually entered song ID.","solutions":["Verify the pasted URL matches the formats documented in the plugin's `hints.importMusicItem` (shown as panel hints) and re-enter it.","Check network connectivity and retry — remote resolution inside the plugin may have failed silently.","Update the plugin to its latest version; older versions break when the source service changes its share-link format or API.","If the plugin requires auth, set its user variables (userVariables panel) with valid cookies/tokens."],"exampleFix":"// before\nconst result = await plugin.methods.importMusicItem(text);\nif (result) { ... } else {\n    Toast.warn(t(\"toast.failToImportMusic\"));\n}\n// after\nlet result;\ntry {\n    result = await plugin.methods.importMusicItem(text);\n} catch (e: any) {\n    Toast.warn(e?.message ?? t(\"toast.failToImportMusic\"));\n    return;\n}\nif (result && result.id) { ... } else {\n    Toast.warn(t(\"toast.failToImportMusic\"));\n}","handlingStrategy":"validation","validationCode":"const result = await plugin.methods.importMusicItem(text);\nif (!result || typeof result !== \"object\" || !result.id || !result.title) {\n    Toast.warn(t(\"toast.failToImportMusic\"));\n    return;\n}","typeGuard":"function isMusicItem(x: unknown): x is IMusicItem {\n    return !!x && typeof x === \"object\" && typeof (x as any).id !== \"undefined\" && typeof (x as any).title === \"string\";\n}","tryCatchPattern":"try {\n    const result = await plugin.methods.importMusicItem(text);\n    if (!isMusicItem(result)) throw new Error(\"invalid result\");\n    // proceed\n} catch (e: any) {\n    Toast.warn(e?.message ?? t(\"toast.failToImportMusic\"));\n}","preventionTips":["Follow the format hints shown in the import panel (plugin.instance.hints.importMusicItem).","Validate the plugin result shape before opening downstream dialogs.","Keep plugins updated — share-link parsers break when platforms change.","Set required plugin user variables (cookies/tokens) for services that need auth."],"tags":["plugin","import","music","validation"],"backgroundTag":"plugin-import-returned-null","analyzedSha":"d118b18b3d0c904400f7eea7bf99c0ceec6c1aee","analyzedAt":"2026-08-30T11:49:12.932Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}