Skip to content

BUG: report missing impact roots explicitly #1147

Description

@ting-hong-shieh

Describe the bug

Flight.__handle_impact_event() assumes that cubic interpolation always returns exactly one valid root in the current solver step. It already reports multiple valid roots explicitly, but it indexes an empty list when no valid root is found.

The resulting exception does not identify the failed numerical operation:

IndexError: list index out of range

To reproduce

At cb6106a717207dd8fc2dfe1446d80ff75022f21b, make find_roots_cubic_function() return roots outside the open solver interval, such as [-1 + 0j, 2 + 0j] for a one-second step, and call the impact event handler. valid_t_root is empty and valid_t_root[0] raises IndexError.

Expected behavior

The impact handler should report the failed root selection directly, consistent with the existing rail-exit handling:

ValueError: No valid roots found when solving for impact time.

The single-root path should remain unchanged, and multiple valid roots should continue to raise the existing ValueError.

Proposed fix

Check for an empty valid_t_root list before indexing it. Add focused tests for zero, one, and multiple valid roots.

Environment

  • Base SHA: cb6106a717207dd8fc2dfe1446d80ff75022f21b
  • RocketPy 1.13.0
  • Python 3.12.6
  • NumPy 2.5.2
  • SciPy 1.18.0
  • pytest 9.1.1
  • macOS 26.5.2, arm64

Activity

  1. Gui-FernandesBR commented on Aug 14, 2026

    @Gui-FernandesBR
    Member

    solved by #1148

  2. Gui-FernandesBR commented on Nov 2, 2026

    @Gui-FernandesBR
    Member

    Reopened: the fix is merged on develop and will close when v1.14.0 is released to master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Awaiting releaseFixed on develop; closes when the next release reaches master

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions