Skip to content

bug: unable to load schema with an attribute of kind list with regex parameter #7717

@wvandeun

Description

@wvandeun

Component

API Server / GraphQL

Infrahub version

1.5.3

Current Behavior

You are not able to load a schema that defines an attribute of kind List, with a regular expression constraint.

For example:

---
version: "1.0"
nodes:
  - name: Node
    namespace: Testing
    attributes:
      - name: protocols
        kind: List
        optional: true
        parameters:
          regex: "ssh|ping|telnet"

You get the following error message:

Unable to load the schema:
  Node: TestingNode | attributes ({'name': 'protocols', 'kind': 'List', 'optional': True, 'parameters': {'regex': 'ssh|ping|telnet'}}) | Value error, TextAttributeParameters 
can't be used as parameters for List (value_error)

When you use the old syntax, the schema loads, and you can create new objects. But then you run into issue #7654

Expected Behavior

You can load a schema that defines a regex constraint on an attribute of kind List, using the parameters.regex syntax.

Steps to Reproduce

Spin up instance of Infrahub
Try loading this schema

---
version: "1.0"
nodes:
  - name: Node
    namespace: Testing
    attributes:
      - name: name
        kind: Text
        optional: false
      - name: protocols
        kind: List
        optional: true
        parameters:
          regex: "ssh|ping|telnet"

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