quixio/quix-streams

Conflicting settings with passed arguments and environment variables

Closed this issue · 0 comments

This may be considered a bug, but sits on the fence, so raising as a feature request.
When I'm deploying a quixstreams application in the Quix Cloud, there are certain variables my deployment gets injected. This is done, so setup and boiler plate is reduced for most use cases. The problem I'm facing is when I have a setup where I consume from/produce to an external broker, with the other end being the environment's broker. (well, the latter part is optional for this issue)
Example:

app = Application(broker_address=broker_address, ...otherconfigs...) # setting up app against external source
input_topic = app.topic(input_topic_name)

producer_app = Application() # setting up app against environment broker
output_topic = producer_app.topic(output_topic_name)

I get the exception:

Traceback (most recent call last):
  File "/app/main.py", line 35, in <module>
    app = Application(broker_address=broker_address, ....otherconfigs...)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/quixstreams/app.py", line 219, in __init__
    raise ValueError(
ValueError: Cannot provide both "broker_address" and "quix_sdk_token"

Describe the solution you'd like
I see two immediate solutions:

  1. prioritise argument based config over environment variables. Here I didn't pass sdk token, so it should ignore the one coming from environment variables, as my argument configuration clearly prefers broker address. Maybe log a warning/info.
  2. let me pass quix_sdk_token as None, so I can turn off this behaviour for an application explicitly.

Additional context
Tried with quixstreams 2.4.1, 2.5.1, same exception.