fix(params): guard against inf/nan from safe_evaluate reaching FC upload#1440
Merged
amilcarlucas merged 1 commit intoArduPilot:masterfrom Mar 28, 2026
Merged
Conversation
94b59d2 to
906ae9f
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Guards compute_parameters() against non-finite (inf/nan) results coming from safe_evaluate() so invalid computed values don’t propagate into Par objects and ultimately to flight controller uploads.
Changes:
- Import
math.isfinitefor numeric validation. - Reject non-finite evaluated results with an explicit error/warning path consistent with existing forced vs. derived handling.
- Add Ruff inline ignores for complexity-related linting on
compute_parameters().
ardupilot_methodic_configurator/backend_filesystem_configuration_steps.py
Show resolved
Hide resolved
safe_evaluate() can produce non-finite values (inf, nan) from expressions like exp(1000), log(0), or conditional branches that evaluate to infinity. These values bypass the existing ZeroDivisionError and ValueError exception handlers and flow unchecked through set_forced_or_derived_value() to the flight controller. Add an isfinite() check on the evaluated result before creating the Par object. Non-finite values are now rejected with a descriptive error message, consistent with the existing validation pattern for forced vs derived parameters. Signed-off-by: Yash Goel <yashhzd@users.noreply.github.com>
906ae9f to
d55cfdd
Compare
amilcarlucas
approved these changes
Mar 28, 2026
Collaborator
|
Thanks for this, merged |
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.
Summary
safe_evaluate()can produce non-finite values (inf, nan) from expressions likeexp(1000),log(0), or conditional branches. These values bypass the existingZeroDivisionError/ValueErrorhandlers and flow unchecked throughset_forced_or_derived_value()to the flight controller.Changes
Add an
isfinite()check on the evaluated result incompute_parameters()before creating theParobject. Non-finite values are rejected with a descriptive error message, consistent with the existing validation pattern for forced vs derived parameters.This closes a gap where
isfinite()checks existed for file-loaded parameters and user-entered values, but not for expression-evaluated results.Closes #1438
Signed-off-by: Yash Goel yashhzd@users.noreply.github.com