Skip to content

Conversation

@Lseoksee
Copy link
Contributor

@Lseoksee Lseoksee commented Nov 26, 2025

In the case of the non-standard translation of the Musixmatch provider, the DisplayNames.of() function would return an exception instead of null or undefined, causing Spotify to crash.

Therefore, we modified this to handle exceptions using a try-catch statement.

Summary by CodeRabbit

  • Refactor
    • Improved error handling in the translation menu so label resolution now uses a safe lookup path with an explicit fallback. Labels will reliably display and will fall back to an uppercase language code when resolution fails, preventing UI errors and missing labels.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Nov 26, 2025

Walkthrough

TranslationMenu in CustomApps/lyrics-plus/OptionsMenu.js now resolves musixmatch option labels inside a try/catch and falls back to code.toUpperCase() on exception; it also uses nullish coalescing for the lookup result.

Changes

Cohort / File(s) Summary
Error handling — TranslationMenu
CustomApps/lyrics-plus/OptionsMenu.js
Wraps musixmatchDisplay.of(code) lookup in try/catch; uses label = musixmatchDisplay.of(code) ?? code.toUpperCase() and falls back to code.toUpperCase() if an exception is thrown (replaces prior `musixmatchDisplay.of(code)

Sequence Diagram(s)

sequenceDiagram
    participant UI as TranslationMenu
    participant Lib as musixmatchDisplay

    rect rgba(76,175,80,0.08)
    UI->>Lib: call musixmatchDisplay.of(code)
    alt returns value (non-nullish)
        Lib-->>UI: label
        UI->>UI: use label
    else returns null/undefined
        Lib-->>UI: null/undefined
        UI->>UI: use code.toUpperCase()
    else throws
        Lib--x UI: throws error
        UI->>UI: catch error
        UI->>UI: use code.toUpperCase()
    end
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Single-file, small control-flow change.
  • Review focus:
    • Confirm musixmatchDisplay.of can throw and whether catch scope is appropriate.
    • Verify nullish coalescing preserves prior behavior for falsy-but-not-nullish values.

Possibly related PRs

Suggested reviewers

  • rxri

Poem

🐰 I nudged a label, soft and spry,
Wrapped its lookup so it won't cry,
If musixmatch stumbles or slips away,
Uppercase hops in to save the day.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately describes the main change: fixing an issue with non-standard translations from Musixmatch providers by adding exception handling.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c356c6a and 890bfc8.

📒 Files selected for processing (1)
  • CustomApps/lyrics-plus/OptionsMenu.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • CustomApps/lyrics-plus/OptionsMenu.js

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (2)
CustomApps/lyrics-plus/OptionsMenu.js (2)

130-130: Optional: Remove unnecessary empty string initialization.

The label variable is assigned in both the try and catch blocks, so the empty string initialization is redundant.

Apply this diff:

-				let label = "";
+				let label;
 				try {
 					label = musixmatchDisplay.of(code);
 				} catch (e) {
 					label = code.toUpperCase();
 				}

133-135: Optional: Consider logging the exception for debugging.

While silently falling back is correct for UX, logging the error could help identify problematic language codes during development.

Apply this diff:

 				} catch (e) {
+					console.warn(`[Lyrics Plus] Invalid language code for Musixmatch translation: ${code}`, e);
 					label = code.toUpperCase();
 				}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 651cbbe and 5e260e9.

📒 Files selected for processing (1)
  • CustomApps/lyrics-plus/OptionsMenu.js (1 hunks)
🔇 Additional comments (1)
CustomApps/lyrics-plus/OptionsMenu.js (1)

130-135: I'll help you verify the review comment. Let me start by checking the Intl.DisplayNames API behavior and then examine the actual code context.
<function_calls>
<function_calls>

Intl.DisplayNames.of() throws exception invalid language code RangeError spec

</function_calls>

Now let me examine the actual code in the file:
<function_calls>

find . -name "OptionsMenu.js" -path "lyrics-plus" 2>/dev/null | head -5

</function_calls>

@Lseoksee Lseoksee changed the title fix(lyrics-plus): fix issue with non-standard translations from Musixmatch providers. fix(lyrics-plus): fix issue with non-standard translations from Musixmatch providers Nov 26, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
CustomApps/lyrics-plus/OptionsMenu.js (1)

130-135: Good fix for the crash issue!

The try-catch block correctly prevents the crash when musixmatchDisplay.of(code) throws a RangeError for non-standard language codes. The fallback to code.toUpperCase() is appropriate.

Consider logging the exception for debugging purposes to help identify problematic language codes in the future:

 let label = "";
 try {
 	label = musixmatchDisplay.of(code) || code.toUpperCase();
 } catch (e) {
+	console.warn(`Failed to get display name for language code "${code}":`, e);
 	label = code.toUpperCase();
 }

This would make it easier to track down issues with invalid or non-standard language codes from Musixmatch providers.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5e260e9 and c356c6a.

📒 Files selected for processing (1)
  • CustomApps/lyrics-plus/OptionsMenu.js (1 hunks)

@Lseoksee
Copy link
Contributor Author

fix issue #3592.

@rxri rxri merged commit 4097185 into spicetify:main Nov 27, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants