fix(upload): replace recursive retry with iterative loop in upload_selected_params_workflow#1429
fix(upload): replace recursive retry with iterative loop in upload_selected_params_workflow#1429yashhzd wants to merge 1 commit intoArduPilot:masterfrom
Conversation
6fb52a7 to
4d83cd3
Compare
There was a problem hiding this comment.
Pull request overview
This PR fixes the retry behavior in upload_selected_params_workflow by replacing a recursive retry call with an iterative loop, addressing incorrect callback argument ordering, unbounded recursion risk, and redundant side effects during recursion unwind.
Changes:
- Replace recursive retry with a
while should_retryloop. - Recreate progress callbacks each retry iteration and keep retry prompting in-loop.
- Ensure
_write_current_file()and_at_least_one_changedreset run exactly once after the loop completes.
| logging_info(_("All parameters uploaded to the flight controller successfully")) | ||
| if should_retry: | ||
| continue | ||
| # If not retrying, continue without success message |
There was a problem hiding this comment.
The comment “If not retrying, continue without success message” is misleading after the refactor: there is no continue in the non-retry branch, and execution will still fall through to later logic (e.g., diff export) before exiting the loop. Update the comment to reflect the actual control flow (e.g., “If not retrying, fall through without success message”) or restructure the branches to match the wording.
| # If not retrying, continue without success message | |
| # If not retrying, fall through without success message |
Anyway, good that you fixed all 3 |
thank you! |
…lected_params_workflow The recursive retry path had three bugs: 1. Missing get_connection_progress_callback argument — the download callback factory was passed in position 7 (where connection callback belongs), causing wrong progress text on retry and no download progress at all. 2. Unbounded recursion — each retry added a stack frame, risking RecursionError on persistent FC communication issues. 3. Redundant side effects — _write_current_file() and the _at_least_one_changed reset executed once per recursion depth on unwind, not just once. Replace with a while loop that re-runs the entire upload/validate cycle on retry. All callback factories are now correctly re-invoked each iteration, _write_current_file() runs exactly once after the loop exits. Closes ArduPilot#1427 Signed-off-by: Yash Goel <yashhzd@users.noreply.github.com>
4d83cd3 to
a0beb37
Compare
Summary
Fixes three bugs in the retry path of
upload_selected_params_workflow(data_model_parameter_editor.py):Missing
get_connection_progress_callbackargument — the recursive retry call passed only 7 of 8 arguments, causingget_download_progress_callbackto land in position 7 (get_connection_progress_callback's slot). On retry: connection progress showed wrong text, download progress wasNone.Unbounded recursion — each retry created a new stack frame, risking
RecursionErroron persistent FC communication issues.Redundant side effects on unwind —
_write_current_file()and_at_least_one_changed = Falseexecuted once per recursion depth, not once total.Changes
Replace the recursive call with a
while should_retryloop. All callback factories are correctly re-invoked each iteration._write_current_file()runs exactly once after the loop exits.Test plan
_write_current_file()is called exactly once after successful uploadRecursionErroron repeated retriesCloses #1427
Signed-off-by: Yash Goel yashhzd@users.noreply.github.com