Skip to content

Fix auth key casing for multi-word translated labels#5836

Open
wwenrr wants to merge 2 commits intoheartcombo:mainfrom
wwenrr:fix-5835-auth-key-downcase
Open

Fix auth key casing for multi-word translated labels#5836
wwenrr wants to merge 2 commits intoheartcombo:mainfrom
wwenrr:fix-5835-auth-key-downcase

Conversation

@wwenrr
Copy link
Copy Markdown

@wwenrr wwenrr commented Apr 1, 2026

Summary

Fixes the capitalization regression reported in #5835 when human_attribute_name returns a multi-word string (e.g. "Email Address").

Previously this produced:

  • Invalid email Address or password.

With this change it produces:

  • Invalid email address or password.

What changed

  • In Devise::FailureApp#i18n_message, when building authentication_keys:
    • Keep existing behavior for single-word labels (downcase_first fallback)
    • Downcase the whole string for multi-word labels (human_key.include?(" ") ? human_key.downcase : ...)

This preserves behavior for values like "E-Mail" while fixing awkward capitalization for values like "Email Address".

Tests

Added coverage in test/failure_app_test.rb:

  • preserves translation capitalization after auth key replacement

Verification run (manual)

I ran the failure app test file locally in a clean Docker Ruby 3.4 environment:

docker run --rm -v "$PWD":/app -w /app ruby:3.4 bash -lc '
  apt-get update >/dev/null && \
  apt-get install -y --no-install-recommends build-essential git pkg-config libsqlite3-dev >/dev/null && \
  bundle install >/dev/null && \
  bin/test test/failure_app_test.rb
'

Result: 45 runs, 91 assertions, 0 failures, 0 errors, 0 skips.

Copy link
Copy Markdown
Member

@carlosantoniodasilva carlosantoniodasilva left a comment

Choose a reason for hiding this comment

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

Thanks! This may fix the immediate problem (and I'll probably apply it soon), but I'm afraid we're going to be playing whack-a-mole with this translation thing 😅

Anyway, let's give it another try before I decide to revert it all back and try a different approach.

Note: there are failures for mongoid, it needs to have translations stored as well.

@carlosantoniodasilva carlosantoniodasilva self-assigned this Apr 1, 2026
@carlosantoniodasilva carlosantoniodasilva added this to the 5.0.4 milestone Apr 1, 2026
@wwenrr
Copy link
Copy Markdown
Author

wwenrr commented Apr 1, 2026

Root cause: the new capitalization test only set activerecord translation, but this matrix failures are under DEVISE_ORM=mongoid so it resolved to default "email". I pushed a fix to include matching mongoid.attributes.user.email translation in the test setup (commit a7cd6af). Please re-run CI.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants