Component
infrahubctl
Infrahub SDK version
1.23.0
Current Behavior
The YAML produced by infrahubctl object get <kind> --output yaml cannot be fed back into infrahubctl object load.
For cardinality-many relationships, the YAML formatter exports peer references wrapped in a nested dict:
---
apiVersion: infrahub.app/v1
kind: Object
spec:
kind: TestingGadget
data:
- name: multitool
tags:
data:
- red
- blue
object load accepts two formats for a many relationship: a plain list of HFIDs, or a data: list of dicts describing nested objects. A data: list of HFID strings matches neither, so loading fails validation:
1.tags: Relationship tags doesn't have the right format many / <class 'dict'>
Any kind with a populated Attribute-kind many relationship (for example tags) is affected, because those relationships are fetched by default by object get and always end up in the exported YAML.
Expected Behavior
The output of object get --output yaml should be directly loadable by object load, e.g. infrahubctl object get InfraDevice --output yaml > backup.yml && infrahubctl object load backup.yml should work. The object get help text even shows the > backup.yml workflow, and the formatter docstring states the output is round-trippable.
Steps to Reproduce
- Load a schema with a many relationship of kind
Attribute (e.g. a node with tags pointing to BuiltinTag).
- Create two tags and one object referencing them.
infrahubctl object get TestingGadget --output yaml > gadgets.yml
infrahubctl object load gadgets.yml → fails with the error above.
Reproduced end-to-end with infrahub-testcontainers; the failing round-trip is covered by an integration test (object get → file → object load).
Additional Information
- Origin:
YamlFormatter._node_to_data_entry (infrahub_sdk/ctl/formatters/yaml.py, the many-relationship branch) emits {"data": [<hfids>]}; get_relationship_info (infrahub_sdk/spec/object.py) leaves such a value's format UNKNOWN and validate_related_nodes rejects it.
- Related but distinct: many relationships of kind
Generic are silently omitted from object get output entirely (the SDK only fetches Attribute/Parent-kind many relationships by default), so those never round-trip. Filed separately.
Component
infrahubctl
Infrahub SDK version
1.23.0
Current Behavior
The YAML produced by
infrahubctl object get <kind> --output yamlcannot be fed back intoinfrahubctl object load.For cardinality-many relationships, the YAML formatter exports peer references wrapped in a nested dict:
object loadaccepts two formats for a many relationship: a plain list of HFIDs, or adata:list of dicts describing nested objects. Adata:list of HFID strings matches neither, so loading fails validation:Any kind with a populated
Attribute-kind many relationship (for exampletags) is affected, because those relationships are fetched by default byobject getand always end up in the exported YAML.Expected Behavior
The output of
object get --output yamlshould be directly loadable byobject load, e.g.infrahubctl object get InfraDevice --output yaml > backup.yml && infrahubctl object load backup.ymlshould work. Theobject gethelp text even shows the> backup.ymlworkflow, and the formatter docstring states the output is round-trippable.Steps to Reproduce
Attribute(e.g. a node withtagspointing toBuiltinTag).infrahubctl object get TestingGadget --output yaml > gadgets.ymlinfrahubctl object load gadgets.yml→ fails with the error above.Reproduced end-to-end with
infrahub-testcontainers; the failing round-trip is covered by an integration test (object get→ file →object load).Additional Information
YamlFormatter._node_to_data_entry(infrahub_sdk/ctl/formatters/yaml.py, the many-relationship branch) emits{"data": [<hfids>]};get_relationship_info(infrahub_sdk/spec/object.py) leaves such a value's formatUNKNOWNandvalidate_related_nodesrejects it.Genericare silently omitted fromobject getoutput entirely (the SDK only fetchesAttribute/Parent-kind many relationships by default), so those never round-trip. Filed separately.