Skip to content

Commit 6fac6ce

Browse files
authored
fix(api): tolerate delete of nonexistent pip offset (#7027)
If you delete a pipette offset that doesn't exist, it really shouldn't throw an exception and break a bunch of stuff.
1 parent 91df27f commit 6fac6ce

File tree

3 files changed

+7
-12
lines changed

3 files changed

+7
-12
lines changed

api/src/opentrons/calibration_storage/delete.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,11 @@ def delete_pipette_offset_file(pipette: str, mount: Mount):
135135
offset_dir = config.get_opentrons_path('pipette_calibration_dir')
136136
offset_path = offset_dir / mount.name.lower() / f'{pipette}.json'
137137

138-
_remove_pipette_offset_from_index(pipette, mount)
139-
offset_path.unlink()
138+
try:
139+
_remove_pipette_offset_from_index(pipette, mount)
140+
offset_path.unlink()
141+
except FileNotFoundError:
142+
pass
140143

141144

142145
def clear_pipette_offset_calibrations():

robot-server/tests/integration/test_pipette_offset_access.tavern.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,4 @@ stages:
142142
pipette_id: '321'
143143
mount: 'right'
144144
response:
145-
status_code: 404
145+
status_code: 200

robot-server/tests/service/pipette_offset/test_pipette_offset_management.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,7 @@ def test_delete_pipette_offset_calibration(
4343
resp = api_client.delete(
4444
f'/calibration/pipette_offset?pipette_id={PIPETTE_ID}&'
4545
f'mount={WRONG_MOUNT}')
46-
assert resp.status_code == 404
47-
body = resp.json()
48-
assert body == {
49-
'errors': [{
50-
'status': '404',
51-
'title': 'Resource Not Found',
52-
'detail': "Resource type 'PipetteOffsetCalibration' with id "
53-
"'123&right' was not found"
54-
}]}
46+
assert resp.status_code == 200
5547

5648
resp = api_client.delete(
5749
f'/calibration/pipette_offset?pipette_id={PIPETTE_ID}&'

0 commit comments

Comments
 (0)