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

FHIRPath evaluator should throw when string function is invoked on non-string #3805

Closed
lmsurpre opened this issue Jul 25, 2022 · 1 comment
Closed
Assignees
Labels
bug Something isn't working P2 Priority 2 - Should Have

Comments

@lmsurpre
Copy link
Member

Describe the bug
http://hl7.org/fhirpath/N1/#string-manipulation says this about the String functions in this section:

If there is more than one item, or an item that is not a String, the evaluation of the expression will end and signal an error to the calling environment.

However, users report that our engine returns empty in this case instead of throwing.

Environment
4.11.1

To Reproduce
See https://chat.fhir.org/#narrow/stream/179266-fhirpath/topic/error.20handling

Expected behavior
"the evaluation of the expression will end and signal an error to the calling environment"

Additional context

@lmsurpre lmsurpre added the bug Something isn't working label Jul 25, 2022
@lmsurpre lmsurpre added the P2 Priority 2 - Should Have label Jul 26, 2022
PrasannaHegde1 added a commit that referenced this issue Jul 27, 2022
Signed-off-by: Prasanna Hegde <prasanna.hegde1@ibm.com>
PrasannaHegde1 added a commit that referenced this issue Jul 27, 2022
Signed-off-by: Prasanna Hegde <prasanna.hegde1@ibm.com>
PrasannaHegde1 added a commit that referenced this issue Jul 28, 2022
PrasannaHegde1 added a commit that referenced this issue Jul 28, 2022
PrasannaHegde1 added a commit that referenced this issue Jul 29, 2022
Signed-off-by: Prasanna Hegde <prasanna.hegde1@ibm.com>
lmsurpre added a commit that referenced this issue Jul 29, 2022
issue #3805 - fix FHIRPath evaluator string function error handling
@lmsurpre
Copy link
Member Author

lmsurpre commented Aug 5, 2022

I tried the happy path on various data types including:

  • Resource.id, Element.id, and Extension.url (System.String)
  • Extension.value.as(FHIR.string)
  • Extension.value.as(FHIR.uri)
  • Extension.value.as(FHIR.code)
  • Extension.value.as(FHIR.oid)
  • Extension.value.as(FHIR.uuid)
  • Extension.value.as(FHIR.markdown)
  • Extension.value.as(FHIR.base64Binary)

Interestingly, I found that the implementation for oid and uuid also match values with the prefix (e.g. "id" will always match the "oid" or "uuid" in the prefix, regardless of the actual unique values).
Similarly, I found that the base64Binary variant matches the encoded base64Binary string, not the decoded value.
I have no clue if that is 'correct' or not, but it seems reasonable and so I"m moving on.

I also confirmed the negative cases for

  • more than one item in the input collection
  • an input collection of size 1 where the type is not string

@lmsurpre lmsurpre closed this as completed Aug 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P2 Priority 2 - Should Have
Projects
None yet
Development

No branches or pull requests

2 participants