Skip to content

Infinite recursion in validate() #73

@apdavison

Description

@apdavison

For cases where there is a loop in the graph, validate() fails with an error: RecursionError: maximum recursion depth exceeded while calling a Python object.

Here is a simple example with a direct loop. Longer loops may be possible.

ds1 = omcore.DatasetVersion(
    short_name="ds1",
    is_alternative_version_of=None
)
ds2 = omcore.DatasetVersion(
    short_name="ds2",
    is_alternative_version_of=ds1
)
ds1.is_alternative_version_of = ds2

failures = ds1.validate()

This gives:

target/openminds/base.py:167: in validate
    for key, values in property.validate(value, ignore=ignore).items():
target/openminds/properties.py:137: in validate
    failures.update(item.validate(ignore=ignore))
target/openminds/base.py:167: in validate
    for key, values in property.validate(value, ignore=ignore).items():
target/openminds/properties.py:137: in validate
    failures.update(item.validate(ignore=ignore))
target/openminds/base.py:167: in validate
    for key, values in property.validate(value, ignore=ignore).items():
target/openminds/properties.py:137: in validate
    failures.update(item.validate(ignore=ignore))
E   RecursionError: maximum recursion depth exceeded while calling a Python object
!!! Recursion detected (same locals & position)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions