Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes REST PUT/PATCH behavior so invalid If-Match header values correctly return a structured 400 Bad Request JSON error (instead of bubbling out and producing a 500/empty response), aligning REST error handling with DAB’s DataApiBuilderException conversion path.
Changes:
- Move
DeterminePatchPutSemanticsevaluation intoHandleOperation’stry/catchso invalidIf-Matchvalues are translated into a 400 JSON error response. - Gate
DeterminePatchPutSemanticsso it only applies toUpsert/UpsertIncremental. - Add PUT and PATCH integration tests asserting 400 + expected error message for invalid
If-Matchvalues.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/Service/Controllers/RestController.cs |
Moves If-Match validation into the controller’s exception-handling path to return 400 JSON errors. |
src/Service.Tests/SqlTests/RestApiTests/Put/PutApiTestBase.cs |
Adds PUT test verifying invalid If-Match returns 400 with expected message. |
src/Service.Tests/SqlTests/RestApiTests/Patch/PatchApiTestBase.cs |
Adds PATCH test verifying invalid If-Match returns 400 with expected message. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why make this change?
Closes #3397
What is this change?
When
DeterminePatchPutSemanticsthrew aDataApiBuilderExceptionfor an invalidIf-Matchvalue, the exception was thrown before enteringHandleOperationand thetry-catchblock within. This is where we convertDataApiBuilderExceptioninto structured JSON error response. We therefore move theDeterminePatchPutSemanticscall inside of thetry-catchblock withinHandleOperation, gating the function behind a check of the operation type so that it only applies toUpsertandUpsertIncrementaloperations.How was this tested?
Added a test for
Putand a test forPatchto validate the new behavior.Sample Request(s)
Any valid
PutorPatchwith headers usingIf-Matchwith a value other than*