Skip to content

Conversation

@Genaker
Copy link
Contributor

@Genaker Genaker commented Oct 28, 2025

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.

@m2-assistant
Copy link

m2-assistant bot commented Oct 28, 2025

Hi @Genaker. Thank you for your contribution!
Here are some useful tips on how you can test your changes using Magento test environment.
❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names.

Allowed build names are:
  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here
ℹ️ Run only required test builds during development. Run all test builds before sending your pull request for review.


For more details, review the Code Contributions documentation.
Join Magento Community Engineering Slack and ask your questions in #github channel.

@ct-prd-pr-scan
Copy link

The security team has been informed about this pull request due to the presence of risky security keywords. For security vulnerability reports, please visit Adobe's vulnerability disclosure program on HackerOne or email psirt@adobe.com.

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

Labels

Priority: P3 May be fixed according to the position in the backlog. Progress: pending review

Projects

Status: Pending Review

Development

Successfully merging this pull request may close these issues.

2 participants