Skip to content
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

Validator throws circular reference error for any contained resource that references another contained resource #367

Open
Kasdejong opened this issue Sep 24, 2024 · 2 comments
Assignees

Comments

@Kasdejong
Copy link
Contributor

Kasdejong commented Sep 24, 2024

The Validator throws circular reference error when a contained resource references another contained resource, even when there is no cycle. This is because the internalReferenceNavEvent strips the index from the resolved reference, and so the validation logger cannot distinguish between contained[0] and contained[1]

to replicate:

[TestMethod]
public void NoCircularInContainedResources()
{
    // no circular in contained patients
    var pat = new
    {
        resourceType = "Patient",
        id = "pat1",
        contained = new[]
        {
            new
            {
                resourceType = "Patient",
                id = "pat2a",
                other = new { _type = "Reference", reference = "#pat2b" }
            },
            new
            {
                resourceType = "Patient",
                id = "pat2b",
                other = new { _type = "Reference", reference = "" }
            }
        }
    };

    var result = test(SCHEMA, pat.DictionaryToTypedElement("Patient"));
    result.IsSuccessful.Should().BeTrue();
    result.Evidence.Should().Contain(ass => (ass as IssueAssertion)!.IssueNumber == Issue.CONTENT_REFERENCE_CYCLE_DETECTED.Code); // Passes???
}
@mmsmits
Copy link
Member

mmsmits commented Oct 2, 2024

We will solve this when we have SDK verison 6.
Since we want to introduce reference equality for ScopedNodes

@mmsmits
Copy link
Member

mmsmits commented Oct 2, 2024

We will also need to undo building up the instance path during validation.
(This is a lot of work).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants