Skip to content

Commit e586bfe

Browse files
authored
fix(app): sanitize legacy command text in run log to protect for non string values (#11127)
1 parent efa83d4 commit e586bfe

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

app/src/organisms/RunDetails/CommandText.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,15 @@ export function CommandText(props: Props): JSX.Element | null {
126126
break
127127
}
128128
case 'custom': {
129+
const { legacyCommandText } = displayCommand.params ?? {}
130+
const sanitizedCommandText =
131+
typeof legacyCommandText === 'object'
132+
? JSON.stringify(legacyCommandText)
133+
: String(legacyCommandText)
129134
messageNode =
130-
displayCommand.params?.legacyCommandText ?? displayCommand.commandType
135+
legacyCommandText != null
136+
? sanitizedCommandText
137+
: displayCommand.commandType
131138
break
132139
}
133140
default: {

app/src/organisms/RunDetails/__tests__/CommandText.test.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,19 @@ describe('CommandText', () => {
158158
'Picking up tip from wellName of fake_display_name in fake_labware_location'
159159
)
160160
})
161+
162+
it('renders correct command text for for legacy command with non-string text', () => {
163+
const { getByText } = render({
164+
analysisCommand: null,
165+
runCommand: {
166+
...MOCK_COMMAND_SUMMARY,
167+
commandType: 'custom',
168+
params: {
169+
legacyCommandType: 'anyLegacyCommand',
170+
legacyCommandText: { someKey: ['someValue', 'someOtherValue'] },
171+
},
172+
},
173+
})
174+
getByText('{"someKey":["someValue","someOtherValue"]}')
175+
})
161176
})

0 commit comments

Comments
 (0)