Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(api, shared-data, robot-server): stringify all error info in run log #13942

Merged
merged 5 commits into from
Nov 8, 2023

Conversation

fsinapi
Copy link
Contributor

@fsinapi fsinapi commented Nov 7, 2023

Overview

The GET /runs endpoint was returning a 500 error in some cases as a result of invalid entries in the robot run log. In the specific case of RQA-1872, the cause is a non-string entry in the errorInfo dictionary for an error that failed a run. To get more specific, the issue was that the PipetteOverpressureError exception was being created with an info field with a value field that was an instance of OT3Mount.

Before this PR, our enumerated errors would accept a dictionary with string keys and any value type. This PR changes the classes to force the dictionary values to be strings. The ErrorOccurrence constructor was not performing any validation on its inputs because it was using the construct method, and now it doesn't have to worry about that because any exceptions have to use strings.

In addition, this PR adds a catch for ValidationErrors when getting the State Summary from the Run Store. It will return None, which is already tolerated by the higher calling functions in the GET /runs chain.

Test Plan

Fail a run with an overpressure error on a robot with current edge, then push this branch, and then make sure GET /runs doesn't return a 500 error (there should be an empty state summary for the run that failed).

Changelog

Review requests

Risk assessment

Pretty low, touches error handling that was already broken and stringifies a bunch of error messages.

@fsinapi fsinapi requested review from sfoster1, shlokamin and a team November 7, 2023 22:59
@fsinapi fsinapi self-assigned this Nov 7, 2023
@fsinapi fsinapi requested a review from a team as a code owner November 7, 2023 22:59
Copy link

codecov bot commented Nov 7, 2023

Codecov Report

Merging #13942 (2732439) into edge (d826bfb) will decrease coverage by 0.12%.
Report is 1 commits behind head on edge.
The diff coverage is n/a.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             edge   #13942      +/-   ##
==========================================
- Coverage   70.66%   70.55%   -0.12%     
==========================================
  Files        2508     1631     -877     
  Lines       70726    54259   -16467     
  Branches     8681     3854    -4827     
==========================================
- Hits        49977    38281   -11696     
+ Misses      18626    15304    -3322     
+ Partials     2123      674    -1449     
Flag Coverage Δ
app 38.69% <ø> (-29.39%) ⬇️
g-code-testing 96.44% <ø> (ø)
notify-server 89.13% <ø> (ø)
protocol-designer 45.63% <ø> (ø)
shared-data 73.04% <ø> (ø)
step-generation 84.95% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
api/src/opentrons/hardware_control/api.py 82.42% <ø> (ø)
...entrons/hardware_control/backends/ot3controller.py 67.85% <ø> (ø)
api/src/opentrons/hardware_control/ot3api.py 79.41% <ø> (ø)
.../src/opentrons/protocol_runner/json_file_reader.py 100.00% <ø> (ø)
robot-server/robot_server/runs/run_store.py 100.00% <ø> (ø)
.../python/opentrons_shared_data/errors/exceptions.py 60.59% <ø> (ø)

... and 880 files with indirect coverage changes

Copy link
Member

@sfoster1 sfoster1 left a comment

Choose a reason for hiding this comment

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

Perfect, thanks! Let's log in that except tho

robot-server/robot_server/runs/run_store.py Outdated Show resolved Hide resolved
Copy link
Member

@sfoster1 sfoster1 left a comment

Choose a reason for hiding this comment

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

Awesome, thanks!

@fsinapi
Copy link
Contributor Author

fsinapi commented Nov 8, 2023

Tested on Flexington. Confirmed that the route no longer returns an error, and the app is able to get past the initializing screen. The summary of the run is misleading since it returns a fake empty state summary, we should be sure to follow up on that.

@fsinapi fsinapi merged commit fa44c01 into edge Nov 8, 2023
45 checks passed
@fsinapi fsinapi deleted the RQA-1872-stringify-error-details branch November 8, 2023 15:28
ncdiehl11 pushed a commit that referenced this pull request Nov 14, 2023
…log (#13942)

* fix(shared-data, api): stringify exception details dict to prevent runlog pydantic validation errors
* Add protection for run store to return None if pydantic validation of a  state summary fails
* Log run store errors when they happen
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.

None yet

2 participants