Skip to content

bug: Schema loader allows double underscores in attribute names #20

Description

@polmichel

Component

API Server / GraphQL

Infrahub version

1.9.3

Current Behavior

When loading the a schema the schema loader and validator allows loading a schema where the attributes contain double underscores.

---
version: "1.0"
nodes:
  - name: TestUnderscore
    namespace: Test
    attributes:
      - name: name
        kind: Text
      - name: name__asc
        kind: Text

Probably there is the same problem with relationships. In isolation the above schema actually works but there a are a few places in the code that assumes that a double underscore will be a separator that is not connected to the name of the attribute, a common example is path values which will impact computed attributes. A common way to refer to the name attribute above would be name__value.

Expected Behavior

We should reject a schema that looks like this. A problem though is that we don't know if there is anyone who has such a schema in their database now and as such forbidding it would be a breaking change. This bug surfaced when considering the impact of opsmill#9190.

The best course of action might be to fix this bug in develop for Infrahub 1.10 and list the change as a breaking change in the release notes.

Steps to Reproduce

The above schema combined with a computed attribute that referred to name__asc should probably do the trick. There's also a PR with a failing test here: opsmill#9207

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions