Skip to content

bug: you can load a schema with an optional and unique attribute #6364

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

Open
wvandeun opened this issue Apr 25, 2025 · 0 comments
Open

bug: you can load a schema with an optional and unique attribute #6364

wvandeun opened this issue Apr 25, 2025 · 0 comments
Labels
state/backlog This issue is part of the backlog type/bug Something isn't working as expected

Comments

@wvandeun
Copy link
Contributor

Component

API Server / GraphQL

Infrahub version

1.2.6

Current Behavior

You can load a schema with an attribute defined on a node, that is both optional and unique.
When this is the only unique attribute on the node, it will also be taken as the HFID implicitly.

Once the schema is loaded, you can then create multiple objects with a null value for that optional/unique attribute.

Expected Behavior

You cannot load a schema that has an optional and unique attribute. For backwards compatibility we could consider disabling this with the INFRAHUB_STRICT_MODE environment variable if required.

Steps to Reproduce

  • start instance of Infrahub
  • load this schema
---
version: "1.0"
nodes:
  - name: Object
    namespace: Testing
    attributes:
      - name: name
        kind: Text
        optional: true
        unique: true
      - name: other
        kind: Text
        optional: true
  • check the schema, notice that the HFID is set to the value of the name attribute
  • create 2 nodes with a null value for the name attribute
o1 = client.create("TestingObject", name="", other="foo")
o1.save()
o2 = client.create("TestingObject", name="", other="bar")
o2.save()

Additional Information

No response

@wvandeun wvandeun added the type/bug Something isn't working as expected label Apr 25, 2025
@wvandeun wvandeun changed the title bug: you can load a schema with an optional and unique attribute` bug: you can load a schema with an optional and unique attribute Apr 25, 2025
@wvandeun wvandeun added the group/backend Issue related to the backend (API Server, Git Agent) label Apr 25, 2025
@exalate-issue-sync exalate-issue-sync bot changed the title bug: you can load a schema with an optional and unique attribute bug: you can load a schema with an optional and unique attribute` Apr 25, 2025
@exalate-issue-sync exalate-issue-sync bot added state/need-triage This issue needs to be triaged and removed group/backend Issue related to the backend (API Server, Git Agent) labels Apr 25, 2025
@exalate-issue-sync exalate-issue-sync bot changed the title bug: you can load a schema with an optional and unique attribute` bug: you can load a schema with an optional and unique attribute Apr 25, 2025
@exalate-issue-sync exalate-issue-sync bot added group/backend Issue related to the backend (API Server, Git Agent) and removed state/need-triage This issue needs to be triaged labels Apr 25, 2025
@exalate-issue-sync exalate-issue-sync bot added priority/2 This issue stalls work on the project or its dependents, it's a blocker for a release and removed group/backend Issue related to the backend (API Server, Git Agent) priority/2 This issue stalls work on the project or its dependents, it's a blocker for a release labels Apr 25, 2025
@exalate-issue-sync exalate-issue-sync bot added the state/backlog This issue is part of the backlog label May 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
state/backlog This issue is part of the backlog type/bug Something isn't working as expected
Projects
None yet
Development

No branches or pull requests

2 participants