opsmill / infrahub

Infrahub - A new approach to Infrastructure Management
https://opsmill.com/
GNU Affero General Public License v3.0
148 stars 7 forks source link

bug: Create mutation tries to set default values for read_only attributes #3666

Open ogenstad opened 3 weeks ago

ogenstad commented 3 weeks ago

Component

Frontend UI

Current Behavior

When an attribute of a node is marked as read_only and it has a default value the frontend tries to use this default value in a mutation, the action is rejected by the backend as the attribute doesn't exist in the input schema for the node.

Expected Behavior

The frontend should never attempt to use read_only attributes in a mutation.

Steps to Reproduce

  1. Load this schema to Infrahub:
# yaml-language-server: $schema=https://schema.infrahub.app/develop/schema.schema.json
---
version: '1.0'
nodes:
  - name: Ticket
    namespace: Support
    label: "Ticket"
    display_labels:
      - title__value
    generate_profile: true
    attributes:
      - name: title
        kind: Text
        description: "The title of the ticket"
      - name: system
        description: "The description of the ticket"
        kind: Boolean
        optional: true
        default_value: true
        read_only: true
  1. Try to create a node of this object
  2. Observe that the operation fails and the mutation looks like this:
mutation SupportTicketCreate {
  SupportTicketCreate(data: {title: {value: "test"}, system: {value: true}}) {
    object {
      id
      display_label
      __typename
    }
    ok
    __typename
  }
}

Additional Information

No response