Skip to content

bug: HFID for cardinality many relationships string not being cast to HFID format (list) #731

@FragmentedPacket

Description

@FragmentedPacket

Component

No response

Infrahub SDK version

1.17.0

Current Behavior

When attempting to load an object with a cardinality of many relationship using a list of strings returns that the node couldn't be found in the database:

infrahubctl object load ./objects/
[11:08:56] INFO     Created node: Cisco Systems                                                      
           INFO     Created node: Colocation                                                         
['OrganizationProviderUpsert'] Unable to find the node Colocation / OrganizationService in the 
database.

Expected Behavior

Allow creation of objects with relationships of cardinality of many by passing in a list of strings instead of requiring a list of lists.

Steps to Reproduce

  1. Load the following schema
---
# yaml-language-server: $schema=https://schema.infrahub.app/infrahub/schema/latest.json
version: "1.0"

generics:
  - name: Generic
    namespace: Organization
    label: Organization
    description: An organization represent a legal entity, a company.
    human_friendly_id:
      - name__value
    order_by:
      - name__value
    display_label: "{{ name__value }}"
    icon: mdi:domain
    include_in_menu: true
    attributes:
      - name: name
        kind: Text
        unique: true
        order_weight: 1000
      - name: description
        kind: Text
        optional: true
        order_weight: 1200
      - name: website
        kind: URL
        optional: false
        order_weight: 1300
      - name: support_portal
        kind: URL
        optional: true
        order_weight: 1400
    relationships:
      - name: tags
        peer: BuiltinTag
        cardinality: many
        kind: Attribute
        optional: true
        order_weight: 3000

nodes:
  - name: Service
    namespace: Organization
    description: Services offered by a provider organization.
    human_friendly_id:
      - name__value
    order_by:
      - name__value
    display_label: "{{ name__value }}"
    icon: mdi:domain
    menu_placement: OrganizationGeneric
    include_in_menu: true
    attributes:
      - name: name
        kind: Text
        unique: true
        order_weight: 1000
      - name: description
        kind: Text
        optional: true
        order_weight: 1200
    # relationships:
    #   - name: tags
    #     peer: BuiltinTag
    #     cardinality: many
    #     kind: Attribute
    #     optional: true
    #     order_weight: 3000

  - name: Manufacturer
    namespace: Organization
    description: Device Manufacturer
    icon: mdi:domain
    inherit_from:
      - OrganizationGeneric
    include_in_menu: true
    menu_placement: OrganizationGeneric

  - name: Provider
    namespace: Organization
    description: Circuit or Location Provider
    icon: mdi:domain
    inherit_from:
      - OrganizationGeneric
    include_in_menu: true
    menu_placement: OrganizationGeneric
    relationships:
      - name: services_offered
        peer: OrganizationService
        cardinality: many
        optional: false
        kind: Attribute
        direction: outbound
  1. Attempt to load the object file
---
apiVersion: infrahub.app/v1
kind: Object
spec:
  kind: OrganizationManufacturer
  data:
    - name: "Cisco Systems"
      description: "Cisco Systems, Inc. is an American multinational technology conglomerate headquartered in San Jose, California, in the center of Silicon Valley. Cisco develops, manufactures, and sells networking hardware, software, telecommunications equipment and other high-technology services and products."
      website: "https://www.cisco.com"
      support_portal: "https://www.cisco.com/c/en/us/support/index.html"
---
apiVersion: infrahub.app/v1
kind: Object
spec:
  kind: OrganizationService
  data:
    - name: "Colocation"
      description: "Colocation services provide businesses with secure, reliable, and scalable data center space to house their IT infrastructure. These services typically include power, cooling, physical security, and network connectivity, allowing companies to focus on their core operations while benefiting from the expertise and resources of the colocation provider."
---
apiVersion: infrahub.app/v1
kind: Object
spec:
  kind: OrganizationProvider
  data:
    - name: "Equinix"
      website: "https://www.equinix.com"
      services_offered:
        - "Colocation"

Additional Information

No response

Metadata

Metadata

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