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: relationship to generic peer with wrong identifier leads to graphql error #4207

Closed
fatih-acar opened this issue Aug 28, 2024 · 0 comments
Assignees
Labels
group/backend Issue related to the backend (API Server, Git Agent) type/bug Something isn't working as expected

Comments

@fatih-acar
Copy link
Contributor

fatih-acar commented Aug 28, 2024

Component

API Server / GraphQL

Infrahub version

0.15.3

Current Behavior

When using the following schema:

# yaml-language-server: $schema=https://schema.infrahub.app/infrahub/schema/latest.json
---
version: '1.0'
generics:
  - name: Backup
    namespace: Cloud
    attributes:
      - name: created_at
        kind: DateTime
    relationships:
      - cardinality: one
        identifier: backup__instance
        name: instance
        optional: false
        kind: Attribute
        peer: CloudInstance
nodes:
  - name: SuperBackup
    namespace: Cloud
    inherit_from:
      - CloudBackup
    attributes:
      - name: updated_at
        kind: DateTime
  - name: Instance
    namespace: Cloud
    attributes:
      - name: created_at
        kind: DateTime
    relationships:
      - cardinality: many
        identifier: instance__backup
        name: backups
        optional: true
        peer: CloudSuperBackup

It is possible to delete a CloudInstance that has a SuperBackup linked to it.
When it is deleted and we try to list SuperBackup nodes, the executed graphql query fails.

This issue doesn't happen when using the schema below because the deletion of the CloudInstance is denied/prevented.

# yaml-language-server: $schema=https://schema.infrahub.app/infrahub/schema/latest.json
---
version: '1.0'
nodes:
  - name: Backup
    namespace: Cloud
    attributes:
      - name: created_at
        kind: DateTime
    relationships:
      - cardinality: one
        identifier: backup__instance
        name: instance
        optional: false
        kind: Attribute
        peer: CloudInstance
  - name: Instance
    namespace: Cloud
    attributes:
      - name: created_at
        kind: DateTime
    relationships:
      - cardinality: many
        identifier: instance__backup
        name: backups
        optional: true
        peer: CloudBackup

Expected Behavior

Deletion of the CloudInstance node should be prevented?

Steps to Reproduce

Use the above schema.
Create a CloudInstance.
Create a SuperBackup linked to this CloudInstance.
Delete the CloudInstance.
List SuperBackups.

Additional Information

No response

@fatih-acar fatih-acar added the type/bug Something isn't working as expected label Aug 28, 2024
@dgarros dgarros added group/backend Issue related to the backend (API Server, Git Agent) state/need-triage This issue needs to be triaged labels Aug 29, 2024
@dgarros dgarros added this to the Infrahub - 0.16.1 milestone Aug 29, 2024
@exalate-issue-sync exalate-issue-sync bot removed this from the Infrahub - 0.16.1 milestone Aug 29, 2024
@exalate-issue-sync exalate-issue-sync bot added this to the Infrahub - 0.16.1 milestone Sep 9, 2024
@exalate-issue-sync exalate-issue-sync bot added state/planned This issue is planned to be worked on in an upcoming release. and removed state/need-triage This issue needs to be triaged labels Sep 9, 2024
@exalate-issue-sync exalate-issue-sync bot removed the state/planned This issue is planned to be worked on in an upcoming release. label Sep 13, 2024
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

3 participants