Skip to content

Conversation

@ricfio
Copy link

@ricfio ricfio commented Dec 1, 2025

  • FIX #3185
  • FIX #3177
  • FIX #3169
  • FIX italian translation for 2fa_key_invalid error

Summary by CodeRabbit

  • Bug Fixes
    • Updated two-factor authentication error messages across all supported languages.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 1, 2025

Walkthrough

This PR simplifies the 2FA invalid key error message across all translation files by removing the {message} placeholder and newline character. The error text is reduced from "{otp_secret} is invalid.\n{message}" to "{otp_secret} is invalid" in the base strings and most translation files, with a corresponding minor adjustment in Italian.

Changes

Cohort / File(s) Summary
Translation Files - 2FA Error Message
custom_components/alexa_media/strings.json, custom_components/alexa_media/translations/bg.json, custom_components/alexa_media/translations/bg_BG.json, custom_components/alexa_media/translations/en.json, custom_components/alexa_media/translations/sv.json
Updated 2fa_key_invalid error message from "{otp_secret} is invalid.\n{message}" to "{otp_secret} is invalid", removing the {message} placeholder and newline.
Italian Translation
custom_components/alexa_media/translations/it.json
Shortened Italian error message from "Chiave 2FA incorporata non valida" to "Chiave 2FA non valida", removing the word "incorporata".

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

  • Changes are repetitive and consistent across all files (same pattern applied uniformly)
  • No logic or behavioral changes—purely localization updates
  • Minor visual verification needed for Italian translation parity

Possibly related PRs

  • PR #3180: Related through the same 2fa_key_invalid error string; that PR modifies config_flow for the otp_secret placeholder while this PR removes the message placeholder from translations.

Suggested reviewers

  • alandtse

Poem

🔑 The 2FA error message, now lean and mean,
Stripped of its chatter, crystal clear is seen—
Across translations wide, from Swedish to Bulgarian,
One simpler path to guide the user on their way! ✨

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR modifies translation strings but does not address the core requirement: adding the 'message' key to description_placeholders in config_flow.py. Add 'message' key to description_placeholders in config_flow.py where 2fa_key_invalid errors are raised to fix the root cause described in issue #3185.
Out of Scope Changes check ⚠️ Warning Translation updates are in scope but represent a workaround rather than fixing the root cause of the issue. The PR should primarily focus on adding the missing 'message' placeholder to description_placeholders in config_flow.py as required by issue #3185, not just removing it from translations.
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: remove message placeholder from 2fa_key_invalid error' accurately describes the main change: removing the {message} placeholder from 2FA error strings across multiple translation files.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

@ricfio ricfio changed the title Fix 2FA key invalid placeholder fix: fix 2FA key invalid placeholder Dec 1, 2025
@ricfio ricfio changed the title fix: fix 2FA key invalid placeholder fix: remove message placeholder from 2fa_key_invalid error translations Dec 1, 2025
@alandtse
Copy link
Owner

alandtse commented Dec 1, 2025

Thanks. Only strings.json needs to be modified. Others are autogenerated on build so all changes will be wiped. Please keep only strings.json.

@ricfio
Copy link
Author

ricfio commented Dec 1, 2025

Thanks. Only strings.json needs to be modified. Others are autogenerated on build so all changes will be wiped. Please keep only strings.json.

Ah ok, sorry, I didn’t know that… now I’ve changed only the placeholder in strings.json.

@ricfio ricfio changed the title fix: remove message placeholder from 2fa_key_invalid error translations fix: remove message placeholder from 2fa_key_invalid error Dec 1, 2025
@alandtse
Copy link
Owner

alandtse commented Dec 2, 2025

@danielbrunt57 I believe your change removed the message. Please confirm it's not actually used and approve.

@danielbrunt57
Copy link
Collaborator

danielbrunt57 commented Dec 2, 2025

@danielbrunt57 I believe your change removed the message. Please confirm it's not actually used and approve.

I approve.

I've confirmed that the current config_flow.py doesn't pass the "message" placeholder thus creating an error since the current strings.json expects it. I don't see any other PR's from myself or others that reinstates a "message" placeholder so this PR is required.

I'm working up a different scheme which checks the key the user input and will pass different messages depending on what they input (TOTP code, incorrectly formatted 2SV key, etc.) so they are better informed of the mistake they made. However, to permit translation of different messages, I'll need to add additional translatable 2fa_key_invalid keys with different messages embedded (rather than placeholders) each will use just the "otp_secret" they input.

Copy link
Collaborator

@danielbrunt57 danielbrunt57 left a comment

Choose a reason for hiding this comment

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

I've confirmed that the current config_flow.py doesn't pass the "message" placeholder thus creating an error since the current strings.json expects it. I don't see any other PR's from myself or others that reinstates a "message" placeholder so this PR is required.

@alandtse
Copy link
Owner

alandtse commented Dec 3, 2025

I thought we use to have a message, are you saying it's totally gone now? @danielbrunt57 If it makes sense to drop the message that's fine, but I don't want to lose info if it was inadvertent.

@danielbrunt57
Copy link
Collaborator

I thought we use to have a message, are you saying it's totally gone now? @danielbrunt57 If it makes sense to drop the message that's fine, but I don't want to lose info if it was inadvertent.

Nope. In the past there were no placeholders at all. This is v5.7.12 strings.json: "2fa_key_invalid": "Invalid Authenticator App key for Amazon 2SV".

I attempted to improve what the user saw for an error message but with the myriad of conflicting PR's, my strings.json PR that added {otp_secret} and {message} got messed up. This PR corrects my error and I will regroup and retry as I now have a better approach in mind which will use multiple different "2fa_key_invalid" strings (i.e. "2fa_key_invalid_1", "2fa_key_invalid_2", etc., or something like that) and depending on whether they entered a 6-digit OTP code or an improper key: too short/too long/fails to generate OTP code, etc. (if I can think of any other scenario) will present an informative error message in their language. The message will not be passed but by using different strings, the text can be different and will be translated with the goal being to make the error messages more intelligent, informative & easy to read which hopefully will result in fewer support issues!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants