Skip to content

bug: SDK client store default branch does not get updated when we change the client's default_branch branch #402

Open
@wvandeun

Description

@wvandeun

Component

Python SDK

Infrahub SDK version

1.12.0

Current Behavior

When you change the default_branch on a SDK client object, it doesn't change the default_branch of that client's store.

This leads to a situation where an object cannot be retrieved from the store.

from infrahub_sdk import InfrahubClientSync

client = InfrahubClientSync(address="https://demo.infrahub.app")

device = client.get("InfraDevice", name__value="atl1-edge1")
assert client.store.get(device.id) # works, store and client default_branch match

client.branch.create("random")

client.store.get(key=device.id, branch="random") # Raise, expected

client.default_branch = "random"
device2 = client.get("InfraDevice", name__value="atl1-core1")

client.store.get(device2.id) # Raise because the default_branch in the store is main, but the object is store for the random branch

device ==  client.store.get(device.id) # TRUE! This works because the store default_branch is still main

Expected Behavior

The store default_branch gets updated whenever we update the SDK's default_branch.

Steps to Reproduce

from infrahub_sdk import InfrahubClientSync

client = InfrahubClientSync(address="https://demo.infrahub.app")

device = client.get("InfraDevice", name__value="atl1-edge1")
assert client.store.get(device.id) # works, store and client default_branch match

client.branch.create("random")

client.store.get(key=device.id, branch="random") # Raise, expected

client.default_branch = "random"
device2 = client.get("InfraDevice", name__value="atl1-core1")

client.store.get(device2.id) # Raise because the default_branch in the store is main, but the object is store for the random branch

device ==  client.store.get(device.id) # TRUE! This works because the store default_branch is still main

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bugSomething isn't working as expected

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions