Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default client get secret from env vars limits compatibility with cloud runtimes #180

Open
zaklein opened this issue May 18, 2024 · 1 comment

Comments

@zaklein
Copy link

zaklein commented May 18, 2024

Hi there :)

I'm trying to migrate from the faunadb to the fauna Python client. My specific use case involves running an automated process on a platform called Pipedream. I can't initiate the fauna Client, seemingly due to an issue related to the given runtime not supporting the attempt to retrieve the "FAUNA_SECRET" environment variable. To help set the context, here's the Python code I'm running in Pipedream:

from fauna.client import Client
db_client = Client(secret="abc") # actual key redacted

This is leading to the error message:

Traceback (most recent call last):

  File "/nano-py/pipedream/worker.py", line 137, in execute
    user_retval = handler(pd)
                  ^^^^^^^^^^^

  File "/tmp/__pdg__/dist/code/f3f82eb5747d9e59b7038eb7fc82c2dc2557fdccd09bbf910b13851e405e5b35/code.py", line 26, in handler
    db_client = Client(secret=db_secret)
                ^^^^^^^^^^^^^^^^^^^^^^^^

  File "/tmp/__pdg__/dist/python/fauna/client/client.py", line 94, in __init__
    self._set_endpoint(endpoint)

  File "/tmp/__pdg__/dist/python/fauna/client/client.py", line 574, in _set_endpoint
    endpoint = _Environment.EnvFaunaEndpoint()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/tmp/__pdg__/dist/python/fauna/client/utils.py", line 63, in __call__
    os.environ.get(

TypeError: dict.get() takes no keyword arguments

The same code works for me locally (same versions for Python and fauna), so it seems like a Pipedream runtime problem. It'd be great if we could control this default "FAUNA_SECRET" environment variable behaviour to extend the compatibility of fauna across runtime contexts. For example, something like:

client = Client(secret=db_secret, default_key_location=False)

Please let me know if you have any follow up questions.
Thanks very much,
Zach

@marrony
Copy link
Contributor

marrony commented May 29, 2024

@zaklein by the stack trace you copied looks like the driver is trying to find FAUNA_ENDPOINT env variable, as a temporary solution can you try to specify endpoint to Client constructor and see if it helps:

from fauna.client import Client
db_client = Client(secret="abc", endpoint="https://db.fauna.com")

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

No branches or pull requests

2 participants