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

VersionId parsing from headers in Spark.Web does not support the Weak ETags specified in FHIR API #713

Open
JeremiahSanders opened this issue May 1, 2024 · 2 comments

Comments

@JeremiahSanders
Copy link

JeremiahSanders commented May 1, 2024

Describe the bug
Per HL7 R4 documentation, Resource VersionId values, when included in headers, are considered "weak ETags" (source).

In the reference FhirController implementation, the header value is simply extracted as-is (without stripping off W/" and trailing "). Reference Spark.Web source.

NOTE: This is not a bug in the Spark package itself; rather it's a problem in the reference Spark.Web implementation.

This results in errors when performing version-aware updates. Spark rejects the request because the version from the request contains the weak ETag formatting.

To Reproduce

Steps to reproduce the behavior:

  1. Create a new FHIR resource of any desired type in your Spark FHIR server.
  2. Retrieve its current version.
  3. Modify it.
  4. Use Hl7.Fhir.R4 NuGet package and its FhirClient.UpdateAsync with versionAware parameter set to true to HTTP PUT the updated version (requires the server to use the Spark.Web code linked above).
  5. Receive a FHIR exception.

Expected behavior
Expectation is that the update will be accepted if the submitted resource version matches current on the server.

Spark version

  • Version: 2.1.0

Operating system + Database

  • OS: Linux and Windows tested
  • Database: MongoDB

Container service / Cloud infrastructure:

  • Container service: Docker and AWS ECS tested
  • Cloud provider: Local and AWS tested
  • Cloud infrastructure: Containers
  • Database as a service: local MongoDB and AWS DocumentDB with Mongo API tested

Additional context
I have successfully verified that Spark handles the version correctly if the header parsing is corrected. E.g., via use of a """^W/"(\d+)"$""" Regex to extract the id from the weak ETag.

@kennethmyhra
Copy link
Collaborator

Thanks for the report @JeremiahSanders, do you have a fix already in place that could be PR'ed?

@JeremiahSanders
Copy link
Author

JeremiahSanders commented May 2, 2024

@kennethmyhra : Unfortunately, no, I don't have a PR-able fix.

However, after additional testing, I discovered that there is a problem with version-aware updates within FHIR transaction requests. (I submitted that separately, under #714 .) I mention that because there may be some aspect of that issue's resolution which might impact how this issue is resolved. I.e., my workaround of stripping the prefix and suffix from the header's value before submission to IFhirService.UpdateAsync(IKey,Resource) might conflict with whatever resolution is identified for #714 .

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

2 participants