{"record":{"id":"ae7b50eef92e9abe","repo":"maotoumao/MusicFree","slug":"panel-musicitemlyricoptions-settingfail","errorCode":null,"errorMessage":"panel.musicItemLyricOptions.settingFail","messagePattern":"panel\\.musicItemLyricOptions\\.settingFail","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/components/panels/types/musicItemLyricOptions.tsx","lineNumber":151,"sourceCode":"            icon: \"arrow-up-tray\",\r\n            title: t(\"panel.musicItemLyricOptions.uploadLocalLyric\"),\r\n            async onPress() {\r\n                try {\r\n                    const result = await getDocumentAsync({\r\n                        copyToCacheDirectory: true,\r\n                    });\r\n                    if (result.canceled) {\r\n                        return;\r\n                    }\r\n                    const pickedDoc = result.assets[0].uri;\r\n                    const lyricContent = await readAsStringAsync(pickedDoc, {\r\n                        encoding: \"utf8\",\r\n                    });                    await lyricManager.uploadLocalLyric(musicItem, lyricContent);\r\n                    Toast.success(t(\"toast.settingSuccess\"));\r\n                    hidePanel();\r\n                } catch (e: any) {\r\n                    console.log(e);\r\n                    Toast.warn(t(\"panel.musicItemLyricOptions.settingFail\", {\r\n                        reason: e?.message,\r\n                    }));\r\n                }\r\n            },\r\n        },\r\n        {\r\n            icon: \"arrow-up-tray\",\r\n            title: t(\"panel.musicItemLyricOptions.uploadLocalLyricTranslation\"),\r\n            async onPress() {\r\n                try {\r\n                    const result = await getDocumentAsync({\r\n                        copyToCacheDirectory: true,\r\n                    });\r\n                    if (result.canceled) {\r\n                        return;\r\n                    }\r\n                    const pickedDoc = result.assets[0].uri;\r\n                    const lyricContent = await readAsStringAsync(pickedDoc, {\r","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/maotoumao/MusicFree/blob/d118b18b3d0c904400f7eea7bf99c0ceec6c1aee/src/components/panels/types/musicItemLyricOptions.tsx#L133-L169","documentation":"This is a user-facing toast shown when uploading a local lyric file for a music item fails. The onPress handler calls lyricManager.uploadLocalLyric(musicItem, lyricContent) after reading a local .lrc file; any exception thrown (file read error, media library write failure, invalid musicItem) is caught and surfaced as this toast with the underlying exception message as 'reason'.","triggerScenarios":"Tapping 'set lyric from local file' when the lyric file read succeeds but lyricManager.uploadLocalLyric throws — e.g. musicItem has no valid id/platform, the media library rejects the write, or lyricContent is empty/invalid.","commonSituations":"User picks an unsupported or empty .lrc file; the selected track is from a plugin whose musicItem lacks a stable id so association fails; filesystem permission issues on the device; plugin media lib not supporting local lyrics.","solutions":["Check the console.log(e) output and fix the underlying reason shown in the toast","Verify the musicItem comes from a plugin/media source that supports local lyric association (has valid platform/id)","Ensure the selected lyric file is a valid, non-empty .lrc with utf8 encoding","Update or reinstall the media plugin responsible for the track"],"exampleFix":"// before\nawait lyricManager.uploadLocalLyric(musicItem, lyricContent);\n// after\nif (!musicItem?.id || !lyricContent?.trim()) {\n    throw new Error('invalid music item or empty lyric file');\n}\nawait lyricManager.uploadLocalLyric(musicItem, lyricContent);","handlingStrategy":"try-catch","validationCode":"// before upload\nif (!musicItem?.id || !lyricContent?.trim()) {\n    Toast.warn('请选择有效的歌词文件');\n    return;\n}","typeGuard":"function isValidMusicItem(m: any): m is IMusicItem {\n    return !!m && typeof m.id !== 'undefined' && typeof m.platform === 'string';\n}","tryCatchPattern":"try {\n    await lyricManager.uploadLocalLyric(musicItem, lyricContent);\n    Toast.success(t('toast.settingSuccess'));\n} catch (e: any) {\n    console.warn(e);\n    Toast.warn(t('panel.musicItemLyricOptions.settingFail', { reason: e?.message }));\n}","preventionTips":["Validate the .lrc file is non-empty and utf8 before upload","Only offer the option for tracks whose plugin supports local lyrics","Keep the musicItem reference fresh (not stale from a closed panel)"],"tags":["lyrics","file-upload","toast"],"backgroundTag":"local-lyric-upload-failed","analyzedSha":"d118b18b3d0c904400f7eea7bf99c0ceec6c1aee","analyzedAt":"2026-08-30T11:49:12.932Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}