Component
Python SDK
Infrahub SDK version
1.1.0
Current Behavior
When you provide a single node for a relationship of cardinality many when creating a new a new node, the SDK correctly detects that this is an invalid scenario and raises an exception
ValueError: Unexpected format for pod found a <class 'infrahub_sdk.node.InfraPodInfrahubNodeSync'>, InfraPod (1810d2ce-5f36-5c88-32b5-c51e64ae0d8f)
However the error message is not really clear.
Expected Behavior
Provide a clearer error message to indidcate that we were expecting a list of object since this is a cardinality many relationship.
Steps to Reproduce
- spin up infrahub
- load this schema
---
version: "1.0"
nodes:
- name: Pod
namespace: Infra
attributes:
- name: name
kind: Text
optional: false
unique: true
- name: IPPrefix
namespace: Test
include_in_menu: false
inherit_from:
- "BuiltinIPPrefix"
description: "IPv4 or IPv6 network"
icon: "mdi:ip-network"
label: "IP Prefix"
attributes:
- name: network_name
kind: Text
description: "Name of the network"
- name: gateway_address
kind: IPHost
description: "Gateway address in CIDR notation"
relationships:
- name: pod
peer: InfraPod
optional: true
cardinality: many
- open a Python REPL and execute the following code
from infrahub_sdk import InfrahubClientSync, Config
client = InfrahubClientSync(config=config)
pod = client.create("InfraPod", name="pod")
pod.save()
prefix = client.create("TestIPPrefix", network_name="zzz", gateway_address_cidr="10.0.0.1/24", pod=pod)
prefix.save()
Additional Information
No response
Component
Python SDK
Infrahub SDK version
1.1.0
Current Behavior
When you provide a single node for a relationship of cardinality many when creating a new a new node, the SDK correctly detects that this is an invalid scenario and raises an exception
However the error message is not really clear.
Expected Behavior
Provide a clearer error message to indidcate that we were expecting a list of object since this is a cardinality many relationship.
Steps to Reproduce
Additional Information
No response