Infisical / infisical-python

♾ Official Infisical SDK for Python
https://infisical.com/
MIT License
32 stars 7 forks source link

`get_secret` not falling back to `os.environ` #48

Closed harveysanders closed 10 months ago

harveysanders commented 11 months ago

According to the README

"By default, get_secret() fetches and returns a personal secret. If not found, it returns a shared secret, or tries to retrieve the value from os.environ."

In my local environment, I have a variable set:

local

INFISICAL_TEST_VAR=infisical-dev-value

In my development env on Infisical, INFISICAL_TEST_VAR is not set.

I would expect client.get_secret("INFISICAL_TEST_VAR") to fall back to my local env's value, but that does not happen: Screen Shot 2023-08-07 at 2 37 45 PM

Looking at the code, I see a call to get_fallback_secret() https://github.com/Infisical/infisical-python/blob/main/infisical/helpers/client.py#L106 However, it looks like it is set to return None, as I'm experiencing: https://github.com/Infisical/infisical-python/blob/main/infisical/services/secret_service.py#L50-L56

There do not appear to be any tests to check this fallback behavior.

Thanks for your help.

gaby commented 10 months ago

@harveysanders this was fixed in https://github.com/Infisical/infisical-python/commit/a72e48c77ba4048c6b45068e25d19976683b6dc3

gaby commented 10 months ago

@harveysanders Can you close this issue, once you test it fixes your issue?

harveysanders commented 10 months ago

@gaby sure! I can probably get to it later today

harveysanders commented 10 months ago

@gaby I just remembered that we removed the Python client from the codebase and are now using integrations. The code looks like it should work, though it might be helpful to add a test for fallback. I'm going to close this for now and reopen it if I encounter the issue again.

Thanks!