Skip to content

Commit 8739d72

Browse files
fix(api): Actually ignore errors that are marked as ignorable (#15850)
1 parent 5d39889 commit 8739d72

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

api/src/opentrons/protocol_engine/clients/transports.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,11 +125,13 @@ async def run_in_pe_thread() -> Command:
125125
)
126126

127127
if command.error is not None:
128-
error_was_recovered_from = (
128+
error_recovery_type = (
129129
self._engine.state_view.commands.get_error_recovery_type(command.id)
130-
== ErrorRecoveryType.WAIT_FOR_RECOVERY
131130
)
132-
if not error_was_recovered_from:
131+
error_should_fail_run = (
132+
error_recovery_type == ErrorRecoveryType.FAIL_RUN
133+
)
134+
if error_should_fail_run:
133135
error = command.error
134136
# TODO: this needs to have an actual code
135137
raise ProtocolCommandFailedError(

api/src/opentrons/protocol_runner/protocol_runner.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -391,13 +391,15 @@ async def _add_and_execute_commands(self) -> None:
391391
)
392392
)
393393
if executed_command.error is not None:
394-
error_was_recovered_from = (
394+
error_recovery_type = (
395395
self._protocol_engine.state_view.commands.get_error_recovery_type(
396396
executed_command.id
397397
)
398-
== ErrorRecoveryType.WAIT_FOR_RECOVERY
399398
)
400-
if not error_was_recovered_from:
399+
error_should_fail_run = (
400+
error_recovery_type == ErrorRecoveryType.FAIL_RUN
401+
)
402+
if error_should_fail_run:
401403
raise ProtocolCommandFailedError(
402404
original_error=executed_command.error,
403405
message=f"{executed_command.error.errorType}: {executed_command.error.detail}",

api/tests/opentrons/protocol_runner/test_protocol_runner.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from opentrons.hardware_control import API as HardwareAPI
2020
from opentrons.legacy_broker import LegacyBroker
2121
from opentrons.protocol_api import ProtocolContext
22+
from opentrons.protocol_engine.error_recovery_policy import ErrorRecoveryType
2223
from opentrons.protocol_engine.types import PostRunHardwareState
2324
from opentrons.protocols.api_support.types import APIVersion
2425
from opentrons.protocols.parse import PythonParseMode
@@ -409,8 +410,14 @@ async def test_run_json_runner_stop_requested_stops_enqueuing(
409410
createdAt=datetime(year=2021, month=1, day=1),
410411
error=pe_errors.ProtocolEngineError(),
411412
),
413+
status=pe_commands.CommandStatus.FAILED,
412414
)
413415
)
416+
decoy.when(
417+
protocol_engine.state_view.commands.get_error_recovery_type(
418+
"protocol-command-id"
419+
)
420+
).then_return(ErrorRecoveryType.FAIL_RUN)
414421

415422
await json_runner_subject.load(json_protocol_source)
416423

0 commit comments

Comments
 (0)