Skip to content

Commit 5859b5b

Browse files
ehelmsclaude
andcommitted
Fix null pointer access in ResourceSelect and SearchSelect
Add consistent null-safe access to response properties to prevent potential null pointer exceptions when response object is null or undefined. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 2906942 commit 5859b5b

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

webpack/JobWizard/steps/form/ResourceSelect.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export const ResourceSelect = ({
4848
// eslint-disable-next-line react-hooks/exhaustive-deps
4949
}, []);
5050
let selectOptions = [];
51-
if (response.subtotal > maxResults) {
51+
if (response?.subtotal > maxResults) {
5252
selectOptions = [
5353
<SelectOption
5454
isDisabled

webpack/JobWizard/steps/form/SearchSelect.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const SearchSelect = ({
3434
// eslint-disable-next-line react-hooks/exhaustive-deps
3535
}, []);
3636
let selectOptions = [];
37-
if (response.subtotal > maxResults) {
37+
if (response?.subtotal > maxResults) {
3838
selectOptions = [
3939
<SelectOption
4040
isDisabled
@@ -60,7 +60,7 @@ export const SearchSelect = ({
6060

6161
const onSelect = (event, selection) => {
6262
if (variant === SelectVariant.typeahead) {
63-
setSelected(response.results.find(r => r.id === selection)); // saving the name and id so we will have access to the name between steps
63+
setSelected(response?.results?.find(r => r.id === selection)); // saving the name and id so we will have access to the name between steps
6464
} else if (variant === SelectVariant.typeaheadMulti) {
6565
if (selected.map(({ id }) => id).includes(selection)) {
6666
setSelected(currentSelected =>
@@ -69,7 +69,7 @@ export const SearchSelect = ({
6969
} else {
7070
setSelected(currentSelected => [
7171
...currentSelected,
72-
response.results.find(r => r.id === selection),
72+
response?.results?.find(r => r.id === selection),
7373
]);
7474
}
7575
}

0 commit comments

Comments
 (0)