robotframework-crypto icon indicating copy to clipboard operation
robotframework-crypto copied to clipboard

[ENHANCEMENT] Improve error messaging for missing key_path in CryptoLibrary

Open febb0e opened this issue 8 months ago • 0 comments

Summary When importing CryptoLibrary without specifying a custom key_path, and the default key file is not present, the current error message is unclear. It would be helpful to provide a more descriptive and actionable message.

Steps to Reproduce

  1. Create a key pair using CryptoLibrary.
  2. Save the keys to a non-default location.
  3. Import CryptoLibrary without specifying the key_path argument.
  4. Run a test case that attempts to decrypt a secret using the library.
*** Settings ***
Library        CryptoLibrary    password=%{PASS}    key_path=

*** Variables ***
${SECRET}    crypt:wUqVNel8Sb1h6mCpk

*** Test Cases ***
Log My Secret
    ${plain}    Get Decrypted Text    ${SECRET}
    Log    ${plain}

Current Behaviour Opening file: /.venv/lib/python3.13/site-packages/CryptoLibrary/utils/../keys/private_key.json No such file or directory TypeError: 'NoneType' object is not subscriptable

This error does not clearly indicate the root cause — that the default private key file was not found and no alternative path was provided.

Proposed Solution Enhance the error message to explicitly inform the user of the missing key file and the need to provide a valid path via the key_path argument.

Suggested Error Message

private_key.json not found in the default path: [<default path>]. If your keys are stored in a non-default location, specify the correct path using the 'key_path' argument when importing CryptoLibrary.

febb0e avatar Jun 12 '25 08:06 febb0e