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: deleting attr from a generic will delete overridden versions on inheriting schema #6073

Open
ajtmccarty opened this issue Mar 18, 2025 · 0 comments
Assignees
Labels
group/backend Issue related to the backend (API Server, Git Agent) type/bug Something isn't working as expected
Milestone

Comments

@ajtmccarty
Copy link
Contributor

Component

No response

Infrahub version

v1.1.9

Current Behavior

Say you have this schema in which NodeB inherits from GenericA and overrides GenericA.color with a new default value

generics:
  - name: GenericA
    attributes:
    - name: color
      default_value: blue
nodes:
  - name: NodeB
    inherit_from: ["GenericA"]
    attributes:
    - name: color
      default_value: green

if you try to delete the attribute color from GenericA, then all color attributes on any instances of NodeA will also be deleted

Expected Behavior

overridden attributes and relationships on node schemas that inherit from a generic should not be affected when an attribute/relationship is deleted from the generic schema

Steps to Reproduce

  1. update the default schema in models/base to add this snippet to OrganizationManufacturer
    attributes:
      - name: description
        kind: Text
        optional: true
        default_value: "the new description"
        order_weight: 1200
  1. start infrahub
  2. load the updated "default" schema
  3. create an OrganizationManufacturer instance
  4. update the description attribute on the OrganizationGeneric schema to delete it by adding the following to the schema
    attributes:
      - name: description
-->     id: <get it from the schema explorer>
-->     state: absent
  1. load the latest version of the schema to infrahub
  2. the description of the OrganizationManufacturer you created in step 4 will still show, but if you attempt to update it, nothing will happen. if you look at your OrganizationManufacturer at the database level, you will see that the description attribute has been deleted

Additional Information

this is probably a bug in NodeAttributeRemoveMigrationQuery01
I suspect that this cypher query removes all attributes of a given name under a given generic, which would include overridden attributes on inheriting schema. the fix is probably to update this query to explicitly ignore schema that have overridden the attribute in question

@ajtmccarty ajtmccarty added the type/bug Something isn't working as expected label Mar 18, 2025
@dgarros dgarros added the group/backend Issue related to the backend (API Server, Git Agent) label Mar 20, 2025
@dgarros dgarros added this to the Backlog milestone Mar 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
group/backend Issue related to the backend (API Server, Git Agent) type/bug Something isn't working as expected
Projects
None yet
Development

No branches or pull requests

2 participants