Skip to content

Commit 755e107

Browse files
committed
fix(params): process all forced parameters instead of stopping at first error
compute_parameters() returned immediately on the first forced parameter error, skipping all remaining forced parameters in the step. This meant a single bad expression (e.g., missing fc_parameters, math domain error, or missing doc metadata) would silently prevent valid forced parameters from being computed. Collect all errors and continue processing, so every valid forced parameter in the step is still evaluated. All errors are joined and returned together, giving the user a complete picture of what failed. Derived parameters already used continue on error — this makes forced parameters consistent with that behavior. Signed-off-by: Yash Goel <yashhzd@users.noreply.github.com>
1 parent be5df96 commit 755e107

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

ardupilot_methodic_configurator/backend_filesystem_configuration_steps.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def __validate_parameters_in_configuration_steps(self, filename: str, file_info:
160160
parameter,
161161
)
162162

163-
def compute_parameters( # pylint: disable=too-many-branches, too-many-arguments, too-many-positional-arguments
163+
def compute_parameters( # noqa: PLR0915 # pylint: disable=too-many-branches, too-many-arguments, too-many-positional-arguments, too-many-statements, too-many-locals
164164
self,
165165
filename: str,
166166
file_info: dict,
@@ -177,6 +177,7 @@ def compute_parameters( # pylint: disable=too-many-branches, too-many-arguments
177177
if parameter_type + "_parameters" not in file_info or not variables:
178178
return ""
179179
destination = self.forced_parameters if parameter_type == "forced" else self.derived_parameters
180+
errors: list[str] = []
180181
for parameter, parameter_info in file_info[parameter_type + "_parameters"].items():
181182
try:
182183
if ("fc_parameters" in str(parameter_info["New Value"])) and (
@@ -189,8 +190,8 @@ def compute_parameters( # pylint: disable=too-many-branches, too-many-arguments
189190
error_msg = error_msg.format(**locals())
190191
if parameter_type == "forced":
191192
logging_error(error_msg)
192-
return error_msg
193-
if not ignore_fc_derived_param_warnings:
193+
errors.append(error_msg)
194+
elif not ignore_fc_derived_param_warnings:
194195
logging_warning(error_msg)
195196
continue
196197

@@ -207,8 +208,8 @@ def compute_parameters( # pylint: disable=too-many-branches, too-many-arguments
207208
error_msg = error_msg.format(**locals())
208209
if parameter_type == "forced":
209210
logging_error(error_msg)
210-
return error_msg
211-
if not ignore_fc_derived_param_warnings:
211+
errors.append(error_msg)
212+
elif not ignore_fc_derived_param_warnings:
212213
logging_warning(error_msg)
213214
continue
214215

@@ -230,8 +231,9 @@ def compute_parameters( # pylint: disable=too-many-branches, too-many-arguments
230231
error_msg = error_msg.format(**locals())
231232
if parameter_type == "forced":
232233
logging_error(error_msg)
233-
return error_msg
234-
logging_warning(error_msg)
234+
errors.append(error_msg)
235+
else:
236+
logging_warning(error_msg)
235237
continue
236238

237239
if filename not in destination:
@@ -246,9 +248,10 @@ def compute_parameters( # pylint: disable=too-many-branches, too-many-arguments
246248
error_msg = error_msg.format(**locals())
247249
if parameter_type == "forced":
248250
logging_error(error_msg)
249-
return error_msg
250-
logging_warning(error_msg)
251-
return ""
251+
errors.append(error_msg)
252+
else:
253+
logging_warning(error_msg)
254+
return "\n".join(errors)
252255

253256
def auto_changed_by(self, selected_file: str) -> str:
254257
if selected_file in self.configuration_steps:

0 commit comments

Comments
 (0)