Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@ShevchenkoRostyslav
Copy link
Contributor

@ShevchenkoRostyslav ShevchenkoRostyslav commented Oct 2, 2025

Fix Error Handling and None Value Processing in Templates Aggregation Pipeline

PR description

This PR addresses critical error handling issues and improves robustness when processing None values in the templates aggregation pipeline and output builders.

Issue

Several error handling and None value processing issues were identified:

  1. Incorrect error handling method calls: The templates aggregation pipeline was calling _handle_execution_error instead of the correct error manager
  2. None value crashes in output builders: Output builders were not properly handling cases where aggregation_result is None, causing crashes during metadata extraction
  3. Missing error handling for input validation: Template/image ID validation errors were not properly caught and handled
  4. Insufficient test coverage: Missing tests for failure scenarios and edge cases with None values

Solution

Error Handling Improvements:

  • Fixed error handling in TemplatesAggregationPipeline: Replaced incorrect _handle_execution_error(None, e) call with proper self.env.error_manager(self.call_trace, e) usage
  • Added comprehensive input validation error handling: Wrapped template/image ID validation logic in try-catch blocks to gracefully handle validation failures
  • Improved pipeline robustness: Ensured pipeline returns proper error responses instead of crashing when validation fails

None Value Processing:

  • Enhanced output builders: Updated MULTIFRAME_IRIS_PIPE_ORB_OUTPUT_SPEC and MULTIFRAME_IRIS_PIPE_SIMPLE_ORB_OUTPUT_SPEC to safely handle None aggregation_result values using walrus operator pattern
  • Safe metadata extraction: Implemented null-safe extractors that return None when aggregation_result is missing rather than raising exceptions

Limitations

  • Error messages are logged but may not provide detailed context about which specific template or image ID caused the validation failure
  • The automatic fallback behavior when errors occur may mask underlying issues in some debugging scenarios
  • Some edge cases with complex error chaining scenarios may still require additional handling

Type

  • Feature
  • Refactoring
  • Bugfix
  • DevOps
  • Testing

Checklist

  • I've made sure that my code works as expected by writing unit tests.
  • I've checked if my code doesn't generate warnings or errors.
  • I've performed a self-review of my code.
  • I've made sure that my code follows the style guidelines of the project.
  • I've commented hard-to-understand parts of my code.
  • I've made appropriate changes in the documentation.

@ShevchenkoRostyslav ShevchenkoRostyslav changed the title Iris multiview/bugfix Fix Error Handling and None Value Processing in Templates Aggregation Pipeline Oct 2, 2025
@ShevchenkoRostyslav ShevchenkoRostyslav self-assigned this Oct 2, 2025
@ShevchenkoRostyslav ShevchenkoRostyslav marked this pull request as ready for review October 2, 2025 12:12
@ShevchenkoRostyslav ShevchenkoRostyslav requested a review from a team as a code owner October 2, 2025 12:12
Copy link
Contributor

@wiktorlazarski wiktorlazarski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for that change. Two things to check/discuss. Otherwise looks good.

try:
# Validate input consistency
if image_ids is not None and len(image_ids) != len(templates):
raise ValueError(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about making this error more specific? Say DifferentImageIdsTemplatesListLen

key="templates_aggregation_metadata",
extractor=lambda ct: {k: v for k, v in ct.get("aggregation_result", {}).items() if k != "iris_template"},
extractor=lambda ct: None
if (agg := ct.get("aggregation_result")) is None
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is walrus operator available in Python3.8 that we support?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, it was introduced in 3.8

@ShevchenkoRostyslav ShevchenkoRostyslav merged commit c52b944 into dev Oct 2, 2025
9 checks passed
@ShevchenkoRostyslav ShevchenkoRostyslav deleted the iris_multiview/bugfix branch October 2, 2025 12:32
ShevchenkoRostyslav added a commit that referenced this pull request Oct 2, 2025
Fix Error Handling and None Value Processing in Templates Aggregation Pipeline (#177)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants