Skip to content

Commit 06edad6

Browse files
authored
fix(app): sanitize legacy command text in new run log to protect for non string values (#11129)
Following up on the work from #11127 which introduced the bug fix to legacy code that is slated for removal accidentally. This adds it to the correct location
1 parent ec1a4bb commit 06edad6

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

app/src/organisms/Devices/ProtocolRun/StepText.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,15 @@ export function StepText(props: Props): JSX.Element | null {
138138
break
139139
}
140140
case 'custom': {
141+
const { legacyCommandText } = displayCommand.params ?? {}
142+
const sanitizedCommandText =
143+
typeof legacyCommandText === 'object'
144+
? JSON.stringify(legacyCommandText)
145+
: String(legacyCommandText)
141146
messageNode =
142-
displayCommand.params?.legacyCommandText ?? displayCommand.commandType
147+
legacyCommandText != null
148+
? sanitizedCommandText
149+
: displayCommand.commandType
143150
break
144151
}
145152
default: {

app/src/organisms/Devices/ProtocolRun/__tests__/StepText.test.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,4 +202,21 @@ describe('StepText', () => {
202202
'Picking up tip from wellName of fake_display_name in fake_labware_location'
203203
)
204204
})
205+
206+
it('renders correct command text for for legacy command with non-string text', () => {
207+
const { getByText } = render({
208+
robotName: ROBOT_NAME,
209+
runId: RUN_ID,
210+
analysisCommand: null,
211+
runCommand: {
212+
...MOCK_COMMAND_SUMMARY,
213+
commandType: 'custom',
214+
params: {
215+
legacyCommandType: 'anyLegacyCommand',
216+
legacyCommandText: { someKey: ['someValue', 'someOtherValue'] },
217+
},
218+
},
219+
})
220+
getByText('{"someKey":["someValue","someOtherValue"]}')
221+
})
205222
})

0 commit comments

Comments
 (0)