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

Consider reporting the name of missing elements in error messages, not just in the path #2734

Closed
alexzautke opened this issue Oct 19, 2023 · 5 comments
Assignees

Comments

@alexzautke
Copy link
Member

alexzautke commented Oct 19, 2023

If the POCO-based parser reports error messages about missing mandatory elements the error message does not contain the name of the element that is missing. Example: "Element has 0 elements, but minium cardinality is 1. At ImplementationGuide.definition, line 10, position 4."

It would be more readable in the form: "Element has 0 elements, but minium cardinality for element '< elementName >' is 1. At ImplementationGuide.definition, line 10, position 4."

Also note that "minium" is spelt wrong.

@mmsmits
Copy link
Member

mmsmits commented Jan 3, 2024

Spelling correction has been fixed in an earlier commit.

About adding the element name: It's really hard to report the name of an element that's not there. Especially in the attribute validation that is used here. I'll discuss with the team.

@ewoutkramer ewoutkramer self-assigned this Jan 10, 2024
@ewoutkramer
Copy link
Member

Note that you can only trigger this validation error on repeating elements with a minimum cardinality, and they are very rare in the spec. The example in ImplementationGuide will even no longer work in R5, since the cardinality changed from min 1 to min 0!

@ewoutkramer
Copy link
Member

ewoutkramer commented Jan 17, 2024

There's a lot of information missing in this bug report, unfortunately, so I was not able to reproduce it.

Assumptions:

  • One of the more recent SDK versions (5.3,0 seems to be in use in Firely Server)
  • This is about the new POCO serializers, specifically the XML one.
  • This is about R4
  • ImplementationGuide.definition itself is not mandatory, but contains one mandatory attribute, resource, which might be what this issue is about (since it is about the element name not mentioned, we will assume this is the name you are missing from the error).
  • This is about the validations in the parser, not about POCO attribute validation.

I have tried the following XML:

<ImplementationGuide xmlns="http://hl7.org/fhir">
  <url value="http://example.org/fhir/ImplementationGuide/example" />
  <name value="Example Implementation Guide" />
  <status value="active" />
  <packageId value="example-ig" />
  <fhirVersion value="4.0.1" />
  <definition>
    <page>
      <nameUrl value="bla" />
      <title value="Title" />
      <generation value="markdown" />
    </page>
  </definition>
</ImplementationGuide>

Note how I have no resource in the definition. If I parse this, the parser reports:

Element has 0 elements, but minimum cardinality is 1. At ImplementationGuide.definition.resource, line 1, position 249)

The path looks more complete than your example (which just says ImplementationGuilde.definition).

If your example differs, or was not from R4, then I might be looking in the wrong direction. I have checked the updates since 5.3.0 and cannot find any changes to the parsers, so it is unlikely that it is caused by a recent change.

Just in case, I tried this with an equivalent json example as well, and also with POCO attribute validation, all of them are providing the necessary details.

@alexzautke
Copy link
Member Author

@ewoutkramer I think this example came from a Simplifier error message, so it's definitely about the new serializers. My point here was more about the readability of the error message than that information is missing in it. Instead of putting the path at the end of the message, my personal preference would be to include it in the message. If I remember correctly the message was formatted in a way that made it appear that the path was not included. That's why I suggested to write it slightly different. Feel free to close if you prefer the current style.

@mmsmits mmsmits changed the title POCO-based XML parser should report name of missing elements in error messages Consider reporting the name of missing elements in error messages, not just in the path Jan 18, 2024
@mmsmits mmsmits added enhancement and removed bug labels Jan 18, 2024
@mmsmits mmsmits transferred this issue from FirelyTeam/firely-net-sdk Mar 14, 2024
@mmsmits mmsmits transferred this issue from FirelyTeam/firely-validator-api Mar 14, 2024
@mmsmits
Copy link
Member

mmsmits commented Mar 14, 2024

We decided not to do this.

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

No branches or pull requests

3 participants