Update Encryption key missing exception message #40250
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Improve the exception text thrown by \Magento\Framework\Encryption\Encryptor::hash() when no encryption key is available.
Before: No key available
After: No encryption key available
The previous message was ambiguous (“key” could refer to array/index/API key). The new message explicitly points to the encryption key, making triage faster and reducing confusion in logs/alerts.
What’s changed
Adjusted the exception message in lib/internal/Magento/Framework/Encryption/Encryptor.php to clarify the missing configuration.
Impact / scope
Affects only the human-readable error text; no functional behavior, signatures, or public APIs changed.
Safer, clearer logs during hashing/encryption operations (e.g., setup, auth, sensitive data hashing).
How to reproduce / test
Start Magento with a missing/empty encryption key (e.g., remove/blank app/etc/env.php ['crypt']['key']).
Trigger any code path that calls Encryptor::hash() (login, password set, etc.).
Observe thrown exception now reads “No encryption key available.”
Backward compatibility
BC-safe: string-only change to an exception message.
No changes to error type, code, or stack traces.
Notes / follow-ups (optional)
Future enhancement: include remediation hints such as:
Verify app/etc/env.php → crypt.key exists.
Rotate or set the key:
bin/magento setup:config:set --key="..."
Consider standardizing similar messages across other encryption-related paths for consistency.