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

Handles invalid header on versioned update #2467

Merged
merged 5 commits into from
Feb 8, 2022

Conversation

rotodd
Copy link
Contributor

@rotodd rotodd commented Feb 2, 2022

Description

When the versioning policy is set to "versioned-update", we require that the most recent version of the resource is provided in the request's if-match header on an update. The specified version must be in ETag format.

Previously, a 500 would be returned if the version was invalid or in an incorrect format. This PR instead returns a 400 Bad Request.

Related issues

Addresses AB#87737.

Testing

Updated the manual test flow to include this case.

A lot of the versioning policy test setup was done in #2457. An automated test for this scenario will be added once that PR merges and this branch can be rebased with those changes.

FHIR Team Checklist

  • Update the title of the PR to be succinct and less than 50 characters
  • Add a milestone to the PR for the sprint that it is merged (i.e. add S47)
  • ✅ Tag the PR with the type of update: Bug, Dependencies, Enhancement, or New-Feature
  • ✅ Tag the PR with Azure API for FHIR if this will release to the Azure API for FHIR managed service (CosmosDB or common code related to service)
  • ✅ Tag the PR with Azure Healthcare APIs if this will release to the Azure Healthcare APIs managed service (Sql server or common code related to service)
  • ✅ CI is green before merge
  • Review squash-merge requirements

Semver Change (docs)

None (bug fix)

@rotodd rotodd requested a review from a team as a code owner February 2, 2022 18:50
@@ -22,7 +22,15 @@ public Task BindModelAsync(ModelBindingContext bindingContext)
WeakETag model = null;
if (!string.IsNullOrWhiteSpace(suppliedWeakETag))
{
model = WeakETag.FromWeakETag(suppliedWeakETag);
try
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this class have unit tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I am not opposed to adding them in, but here is my thought process on why I left them out: we do have unit tests for ETag conversions in WeakETagTests.cs, and the integration test I'll add once PR #2457 is merged should ensure that a 400 is returned when an invalid version is passed in by the user.

I also noticed our other binder class (PartialDateTimeBinder.cs) doesn't have unit tests. Both binder classes only have the BindModelAsync() method, and I'm not confident that adding unit tests for it would add much value (I could be wrong, though).

Let me know your thoughts!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, I just wanted to make sure there was some test coverage for this.

@rotodd rotodd merged commit fa09451 into main Feb 8, 2022
@rotodd rotodd deleted the personal/rotodd/if-match-header-validation branch February 8, 2022 18:37
dustinburson added a commit to microsoft/iomt-fhir that referenced this pull request Aug 2, 2022
…The latest version of the FHIR Client no longer does this automatically. The change occurred as part of this PR microsoft/fhir-server#2467
dustinburson added a commit to microsoft/iomt-fhir that referenced this pull request Aug 2, 2022
* Update packages to latest except Azure Web Job related packages due to backwards compatibility issues.

* Update FhirService to explicitly generate the full e-tag on updates.  The latest version of the FHIR Client no longer does this automatically.  The change occurred as part of this PR microsoft/fhir-server#2467
@sghino
Copy link

sghino commented Oct 11, 2022

The PATCH operation seems to be not possible with the policy version-update. The operation returns the following error: 400 - A valid if-match header is required for resource type 'Organization'

@LTA-Thinking
Copy link
Collaborator

@EXPEkesheth, FYI
@sghino would you mind making an issue for this problem? We don't tend to monitor old PRs.

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

Successfully merging this pull request may close these issues.

None yet

3 participants