Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: cannot update on existing SchemaNode with inheritance from a generic #4051

Closed
wvandeun opened this issue Aug 9, 2024 · 3 comments · Fixed by #4154
Closed

bug: cannot update on existing SchemaNode with inheritance from a generic #4051

wvandeun opened this issue Aug 9, 2024 · 3 comments · Fixed by #4154
Assignees
Labels
group/schema Issue related to some schemas type/bug Something isn't working as expected

Comments

@wvandeun
Copy link
Contributor

wvandeun commented Aug 9, 2024

Component

API Server / GraphQL

Infrahub version

0.16.0.dev0

Current Behavior

When you have a schema node defined and loaded into Infrahub. You may want to update the schema node during the schema development process with a generic that you want to make it inherit from.
This doesn't seem to work and raises an error message:

Unable to load the schema:
  'not_supported': InfraDevice inherit_from None
1

Expected Behavior

The schemanode should be updated and inherit from the generic.

Steps to Reproduce

  • start empty instance of Infrahub
  • load this schema
---
version: "1.0"
generics:
  - name: Generic
    namespace: Infra
    attributes:
      - name: description
        kind: Text
        optional: true
nodes:
  - name: Device
    namespace: Infra
    label: "Device"
    display_labels:
      - name__value
    attributes:
      - name: name
        kind: Text
        unique: true
    relationships:
      - name: tags
        peer: BuiltinTag
        kind: Attribute
        cardinality: many
        optional: true
  • load the new version of the schema, note that InfraDevice now inherites from InfraGeneric
---
version: "1.0"
generics:
  - name: Generic
    namespace: Infra
    attributes:
      - name: description
        kind: Text
        optional: true
nodes:
  - name: Device
    namespace: Infra
    label: "Device"
    inherit_from:
      - InfraGeneric
    display_labels:
      - name__value
    attributes:
      - name: name
        kind: Text
        unique: true
    relationships:
      - name: tags
        peer: BuiltinTag
        kind: Attribute
        cardinality: many
        optional: true
  • infrahubctl will give you an error message
Unable to load the schema:
  'not_supported': InfraDevice inherit_from None
1

Additional Information

No response

@wvandeun wvandeun added the type/bug Something isn't working as expected label Aug 9, 2024
@wvandeun wvandeun changed the title bug: cannot update on existing SchemaNode with a new inheritance bug: cannot update on existing SchemaNode with inheritance from a generic Aug 9, 2024
@dgarros dgarros added the group/schema Issue related to some schemas label Aug 12, 2024
@dgarros dgarros added this to the Infrahub - 0.16 milestone Aug 12, 2024
@dgarros dgarros self-assigned this Aug 13, 2024
@BaptisteGi
Copy link
Contributor

Hey, I have a very similar issue, assuming I load the following schema:

# yaml-language-server: $schema=https://schema.infrahub.app/infrahub/schema/latest.json
---
version: "1.0"
generics:
  - name: Generic
    namespace: Topology
    description: "Generic model for topology."
    label: "Topology"
    icon: "carbon:network-3"
    default_filter: name__value
    display_labels: [name__value]
    order_by: [name__value]
    include_in_menu: true
    attributes:
      - name: name
        kind: Text
        order_weight: 1000
      - name: description
        kind: Text
        order_weight: 1300
        optional: true

nodes:
  - name: MetroTopology
    namespace: Topology
    description: "Represents a topology for a given metro."
    label: "Metro Topology"
    icon: "carbon:network-enterprise"
    menu_placement: "TopologyGeneric"
    inherit_from:
      - TopologyGeneric

Then in a second time I load the exact same but with one more inheritance:

# yaml-language-server: $schema=https://schema.infrahub.app/infrahub/schema/latest.json
---
version: "1.0"
generics:
  - name: Generic
    namespace: Topology
    description: "Generic model for topology."
    label: "Topology"
    icon: "carbon:network-3"
    default_filter: name__value
    display_labels: [name__value]
    order_by: [name__value]
    include_in_menu: true
    attributes:
      - name: name
        kind: Text
        order_weight: 1000
      - name: description
        kind: Text
        order_weight: 1300
        optional: true

nodes:
  - name: MetroTopology
    namespace: Topology
    description: "Represents a topology for a given metro."
    label: "Metro Topology"
    icon: "carbon:network-enterprise"
    menu_placement: "TopologyGeneric"
    inherit_from:
      - TopologyGeneric
      - CoreArtifactTarget # <-- My new inheritance

Here the second load fails with the same message:

> infrahubctl schema load models/topo.yml
Unable to load the schema:
  'not_supported': TopologyMetroTopology inherit_from None
1

@dgarros do you want me to create a separated issue or do you think it falls in the same bucket as this one?

@BaptisteGi
Copy link
Contributor

(I believe it's the same issue as CoreArtifactTarget is a generic, just not user defined ...)

@dgarros
Copy link
Collaborator

dgarros commented Aug 22, 2024

Looks like the same issue, it will be fixed in #4154

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
group/schema Issue related to some schemas type/bug Something isn't working as expected
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants