Skip to content

Ambiguous attributes should not be accepted ? #2403

Open
linkml/linkml-runtime
#352
@vincentkelleher

Description

@vincentkelleher

Describe the bug

In a case where a schema has ambiguous class attributes, the SchemaView.get_slot(...) method should throw an exception rather than returning the first attribute it can find with less details about it.

Here is the test case I used to reproduce the issue :

id: https://examples.org/get-slot-with-attribute#
name: get-slot-with-attribute

prefixes:
  test: https://examples.org/get-slot-with-attribute#

default_prefix: test
default_range: string

classes:
  ClassWithAttributes:
    attributes:
      randomAttribute:
        description: "A random attribute for testing purposes"
        range: integer
        minimum_value: 0
        maximum_value: 999

  ImportantSecondClass:
    description: "Important class to reproduce the error I got as the class loop needs to have at least a 
              second iteration"
    attributes:
      randomAttribute:
        description: "Now you see the ambiguity intensifying ?"
        range: integer
        minimum_value: 0
        maximum_value: 111

In my case, the unexpected behaviour comes from this part of the code base which returns a SlotDefinition with its name only.

I would imagine that attributes are made to bring ease of use but in the case above the user should be forced to define a slot instead through an exception.

What do you think ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething that should work but isn't, with an example and a test case.community-generateddeveloper-dayssmallish tickets that can be considered "maintenance" and fixed within a single session

    Type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions