Skip to content

bug: Having a token exported in env creates pydantic exception when logging with password #654

@BaptisteGi

Description

@BaptisteGi

Component

Python SDK

Infrahub SDK version

1.5

Current Behavior

If I have this in my env variables:

export | grep INFRAHUB
INFRAHUB_ADDRESS=http://localhost:8000
INFRAHUB_API_TOKEN=06438eb2-8019-4776-878c-0941b1f1d1ec

Then try to run this piece of code:

# Test connection and authentication
def hello_world():
    client = InfrahubClientSync(
        config=Config(
            address="https://sandbox.infrahub.app",
            username="otto",
            password="infrahub",
        )
    )

It creates this exception

Traceback (most recent call last):
pydantic_core._pydantic_core.ValidationError: 1 validation error for Config
  Value error, Unable to combine password with token based authentication [type=value_error, input_value={'address': 'https://sand... 'password': 'infrahub'}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.10/v/value_error

Expected Behavior

Either a message clearer or in my opinion what's is in the code should be followed

Steps to Reproduce

  • Export token in env
  • Try to create a client object with username and password

Additional Information

No response

Metadata

Metadata

Assignees

Labels

type/bugSomething isn't working as expected

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions