Skip to content

bug: Mandatory fields with default_value set incorrectly have Optional type in schema protocols #894

@dpeachey

Description

@dpeachey

Component

No response

Infrahub SDK version

1.19.0

Current Behavior

A field that has both optional: false and default_value has an incorrect type generated in the schema protocols. Example field:

- name: enabled
   kind: Boolean
   default_value: true
   optional: false

...has BooleanOptional type in the protocols:

class InfraGenericInterface(CoreNode):
    description: StringOptional
    enabled: BooleanOptional

Expected Behavior

The type should not be Optional. In the above example the type would be Boolean.

Steps to Reproduce

  • Define a field with optional: false and default_value
  • Generate schema protocols

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    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