Skip to content

Conversation

lexDiller
Copy link

Hi there!

I used the methods listed in the docs to import secrets from infisical via the SDK, but I ran into a problem:

Traceback (most recent call last):
File "/app/src/redis_worker/worker.py", line 10, in
from config.secrets_config import get_secret
File "/app/src/config/secrets_config.py", line 28, in
raw = client.secrets.list_secrets(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/infisical_sdk/resources/secrets.py", line 52, in list_secrets
result = self.requests.get(
^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/infisical_sdk/infisical_requests.py", line 88, in wrapper
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/infisical_sdk/infisical_requests.py", line 169, in get
parsed_data = model.from_dict(data) if hasattr(model, 'from_dict') else data
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/infisical_sdk/api_types.py", line 105, in from_dict
secrets=[BaseSecret.from_dict(secret) for secret in data['secrets']],
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/infisical_sdk/api_types.py", line 40, in from_dict
return cls(**filtered_data)
^^^^^^^^^^^^^^^^^^^^
TypeError: BaseSecret.init() missing 2 required positional arguments: 'createdAt' and 'updatedAt'.

So what was done:

  1. Made the createdate and updatedate fields optional
    In the Bazasecret and KmsKey models, these fields are now of type Optional[str] = None, meaning they may be missing (there will be None).

  2. Added processing of different field names ('snake_case' → `camelCase')

  3. The from_dict method of the base model now includes shifting values from the created_at fields. = created At and updated_at = updatedAt

    • This means that if the response from the API comes in snake_case (for example, created_at), the data will be converted to camelCase inside the model, and the constructor will not crash even if the API returns one of two options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant