Handle successful resource update retries correctly - #5025
Handle successful resource update retries correctly#5025Jonny Rylands (jonnyry) with Copilot wants to merge 3 commits into
Conversation
|
Copilot please can you update the CHANGELOG and the api version number |
There was a problem hiding this comment.
🟡 Not ready to approve
The code change appears correct, but the repo’s guidance indicates significant changes should be recorded in CHANGELOG.md and this PR introduces a behavioral bug fix without an entry.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.
Pull request overview
Fixes try_update_with_retries(...) so that when an update succeeds after retrying an CosmosAccessConditionFailedError (etag mismatch), the successful patched Resource is returned to the original caller, and adds regression coverage for the success-after-retry path.
Changes:
- Return the result of the recursive retry call in
try_update_with_retries(...)so successful retries propagate the updatedResource. - Add a test that simulates an etag mismatch on the first patch attempt and success on the second, asserting the updated
Resourceis returned and the expected calls occur.
File summaries
| File | Description |
|---|---|
| api_app/service_bus/helpers.py | Fixes retry recursion to return the successful patched Resource to the original caller. |
| api_app/tests_ma/test_service_bus/test_resource_request_sender.py | Adds regression test to cover the successful retry path and validate call counts/return value. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 2
- Review effort level: Lite
We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.
Done in |
TLDR
This line below missing a
returnwhich causes aAttributeErrorup the call stack. This line is only rarely called when a database update is in retry due to a mismatch in ETag.AzureTRE/api_app/service_bus/helpers.py
Line 133 in 14f49d2
Longer version (Copilot):
What is being addressed
try_update_with_retries(...)retried onCosmosAccessConditionFailedError, but a successful recursive retry did not propagate the patchedResourceback to the caller. The existing tests covered the exhausted-retries case only, so this success path was unverified.How is this addressed
Retry return path
try_update_with_retries(...)result so a successful retry yields the updatedResourceto the original caller.Regression coverage
patch_resource(...)raisesCosmosAccessConditionFailedErrortry_update_with_retries(...)returns the patchedResourcepatch_resource(...)andget_resource_by_id(...)are each called twiceIllustrative change
Update documentation
Update CHANGELOG.md if needed
Increment template version if needed, for guidelines see Authoring templates - versioning