Skip to content

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

@Kasdejong

Description

@Kasdejong

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???
}

Metadata

Metadata

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions