{"record":{"id":"25a2f2988e49fae5","repo":"maotoumao/MusicFree","slug":"panel-associatelrc-toast-fail","errorCode":null,"errorMessage":"panel.associateLrc.toast.fail","messagePattern":"panel\\.associateLrc\\.toast\\.fail","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/components/panels/types/associateLrc.tsx","lineNumber":66,"sourceCode":"                                    const targetCache =\n                                        mediaCache.getMediaCache(targetMedia);\n                                    if (!targetCache) {\n                                        Toast.warn(\n                                            t(\"panel.associateLrc.targetExpired\"),\n                                        );\n                                        // TODO: ERROR CODE\n                                        throw new Error(\"CLIPBOARD TIMEOUT\");\n                                    }\n\n                                    lyricManager.associateLyric(musicItem, {\n                                        ...targetMedia,\n                                        ...targetCache,\n                                    });\n                                    Toast.success(t(\"panel.associateLrc.toast.success\"));\n                                    hidePanel();\n                                } catch (e: any) {\n                                    if (e.message !== \"CLIPBOARD TIMEOUT\") {\n                                        Toast.warn(t(\"panel.associateLrc.toast.fail\"));\n                                    }\n                                    errorLog(\"关联歌词失败\", e?.message);\n                                }\n                            } else {\n                                lyricManager.unassociateLyric(musicItem);\n                                Toast.success(t(\"panel.associateLrc.toast.unlinkSuccess\"));\n                                hidePanel();\n                            }\n                        }}\n                    />\n\n                    <TextInput\n                        value={input}\n                        onChangeText={_ => {\n                            setInput(_);\n                        }}\n                        style={[\n                            style.input,","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/maotoumao/MusicFree/blob/d118b18b3d0c904400f7eea7bf99c0ceec6c1aee/src/components/panels/types/associateLrc.tsx#L48-L84","documentation":"Generic failure toast for the lyric-association flow in AssociateLrc. Any exception thrown while parsing the key or calling lyricManager.associateLyric lands in the catch at associateLrc.tsx:64-69; unless it is the sentinel 'CLIPBOARD TIMEOUT' (error 26), this warning is shown and the error is written via errorLog. The lyric was not associated.","triggerScenarios":"parseMediaUniqueKey(inputValue.trim()) throws on malformed clipboard/input text (associateLrc.tsx:44-46), or lyricManager.associateLyric(musicItem, {...}) rejects (invalid musicItem or merged media object at :58-61).","commonSituations":"Clipboard contains random text that is not a valid media unique key; clipboard read permission denied making input empty-ish; associateLyric called with a musicItem missing required fields; corrupted cache data merged into the association payload.","solutions":["Check errorLog output ('关联歌词失败') for the underlying message to identify parse vs. association failure.","Paste a valid media unique key produced by the app, not arbitrary text.","Ensure musicItem passed to the panel is a complete IMusic.IMusicItem (id, platform, etc.).","Retry after re-caching the target media (see error 26) if the key was valid but its data was stale."],"exampleFix":"// before\n} catch (e: any) {\n    if (e.message !== \"CLIPBOARD TIMEOUT\") {\n        Toast.warn(t(\"panel.associateLrc.toast.fail\"));\n    }\n// after\n} catch (e: any) {\n    if (e.message !== \"CLIPBOARD TIMEOUT\") {\n        if (parseMediaUniqueKeySafe(input)) {\n            Toast.warn(t(\"panel.associateLrc.toast.fail\"));\n        } else {\n            Toast.warn(t(\"panel.associateLrc.invalidKey\"));\n        }\n    }","handlingStrategy":"try-catch","validationCode":"const text = (input ?? (await Clipboard.getString()))?.trim();\nif (!text || !/^\\S+$/.test(text)) {\n    // not a plausible media key — treat as unlink or abort\n    return;\n}","typeGuard":"function isMediaUniqueKey(v: unknown): v is string {\n    return typeof v === 'string' && v.length > 0 && v.includes('#');\n}","tryCatchPattern":"try {\n    const targetMedia = parseMediaUniqueKey(text);\n    lyricManager.associateLyric(musicItem, { ...targetMedia, ...mediaCache.getMediaCache(targetMedia)! });\n} catch (e: any) {\n    errorLog(\"关联歌词失败\", e?.message);\n    Toast.warn(t(\"panel.associateLrc.toast.fail\"));\n}","preventionTips":["Validate clipboard content parses as a media unique key before calling associateLyric.","Confirm musicItem has the required IMusicItem fields before opening the panel.","Route all association failures through errorLog for diagnosis.","Distinguish cache-miss from parse errors to give users accurate toasts."],"tags":["clipboard","lyrics","parse-error","toast"],"backgroundTag":"invalid-media-key","analyzedSha":"d118b18b3d0c904400f7eea7bf99c0ceec6c1aee","analyzedAt":"2026-08-30T11:49:12.932Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}