Repository navigation
fix(http): defensively handle missing optional fields and snake_case keys in HttpRetryOptions.from_json - #353
Conversation
Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
…ields Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
…om_json Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
…payload Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
|
Hi maintainers, Bernd Verst (@berndverst) and andystaples I've opened this PR to address #351 by making I've also added regression tests covering missing fields, explicit Validation is passing: 81 tests passed, and Whenever you have a moment, I'd appreciate your review and feedback. Thank you! |
|
Hardik K (@hardikkaurani) we will not accept PRs for issues that have been opened by the PR author just moments earlier. An issue at minimum requires community discussion or triage from maintainers. No unsolicited PRs please. We already went over this with your previous contribution: #310 (comment) The issue requires triage from andystaples or myself (Bernd Verst (@berndverst)) before we will accept a PR. |
|
Thanks for clarifying. I understand your contribution process and acknowledge that I should have waited for maintainer triage and community discussion before opening this PR. I'll keep this in mind for future contributions and avoid submitting PRs for issues that haven't been discussed or triaged first. Apologies for overlooking this, and thanks for taking the time to clarify the expectations. |
|
Thanks for the contribution. Closing per the explanation in #351 (comment). |
Summary of Changes
Closes #351
In
azure.durable_functions.http.models.HttpRetryOptions.from_json(), deserialization previously accessed optional retry fields (maxRetryIntervalInMilliseconds,retryTimeoutInMilliseconds, andbackoffCoefficient) using direct dictionary subscriptingvalue["..."].When a wire payload omits these optional fields (for example, when serialized with default options or across language SDK boundaries),
from_json()raisedKeyError(e.g.KeyError: 'maxRetryIntervalInMilliseconds'), causing the built-in HTTP orchestrator polling loop (builtin_http_poll_orchestrator) to fail during replay.Furthermore, unlike
DurableHttpResponse.from_json()which defensively handles bothstatus_codeandstatusCode,HttpRetryOptions.from_json()only recognized camelCase keys, rejecting snake_case dictionaries.This change:
.get(), defaultingbackoff_coefficientto1.0,max_retry_intervaltotimedelta(days=6)(matching theHttpRetryOptionsconstructor default when omitted), and preserving explicitNonefor unbounded intervals.first_retry_interval_in_milliseconds,max_number_of_attempts,backoff_coefficient,max_retry_interval_in_milliseconds,retry_timeout_in_milliseconds, andstatus_codes_to_retry).Nonemax intervals, and snake_case configurations.Changes Across Commits
Commit 1:
fix(http): handle missing optional fields in HttpRetryOptions.from_jsonmaxRetryIntervalInMilliseconds,retryTimeoutInMilliseconds, andbackoffCoefficientinHttpRetryOptions.from_json().Commit 2:
fix(http): support snake_case keys in HttpRetryOptions.from_jsonCommit 3:
test(http): verify HttpRetryOptions.from_json with missing optional fieldsNonemax intervals reconstruct correctly.Commit 4:
test(http): verify HttpRetryOptions.from_json with snake_case keysCommit 5:
docs(http): document defensive payload parsing in HttpRetryOptions.from_jsonmodels.pyand document the fix inazure-functions-durable/CHANGELOG.md.Commit 6:
test(http): verify orchestrator execution with partial retry options payloadbuiltin_http_poll_orchestratorsuccessfully runs when provided with a partialretryOptionsdictionary.Verification
pytest tests/azure-functions-durable/test_http_retry.py(81/81 passed)ruff check .(All checks passed)