Skip to content

Commit 858b0bc

Browse files
authored
fix: add specific error reporting around default-selected-variable code (#5689)
1 parent 8e501f3 commit 858b0bc

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/variables/selectors/index.tsx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {AppState, VariableArgumentType, Variable} from 'src/types'
2828

2929
// Utils
3030
import {filterUnusedVars} from 'src/shared/utils/filterUnusedVars'
31+
import {reportErrorThroughHoneyBadger} from 'src/shared/utils/errors'
3132

3233
export const extractVariableEditorName = (state: AppState): string => {
3334
return state.variableEditor.name
@@ -210,7 +211,23 @@ export const getVariable = (state: AppState, variableID: string): Variable => {
210211
}
211212

212213
if (!vari.selected.length && vals.length) {
213-
vari.selected.push(vals[0])
214+
try {
215+
vari.selected.push(vals[0])
216+
} catch (err) {
217+
// Temporary measure to resolve errors relating to pushing into non-extensible object.
218+
reportErrorThroughHoneyBadger(err, {
219+
name: 'Failed to set selected variable to default, zero-indexed value',
220+
context: {
221+
identityState: state.identity,
222+
resourceState: state.resources,
223+
variable: vari,
224+
variableType: vari.arguments.type,
225+
normalizedVariable: vals,
226+
variableLength: vari.selected.length,
227+
normalizedVariableLength: vals.length,
228+
},
229+
})
230+
}
214231
}
215232

216233
return vari

0 commit comments

Comments
 (0)