Skip to content

Commit 2a61016

Browse files
authoredFeb 3, 2025··
Add NPE checks on object.values() calls (#595)
Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com>
1 parent bdaa464 commit 2a61016

File tree

10 files changed

+12
-12
lines changed

10 files changed

+12
-12
lines changed
 

‎public/pages/workflow_detail/components/edit_workflow_metadata_modal.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export function EditWorkflowMetadataModal(
7878
'This workflow name is already in use. Use a different name',
7979
(name) => {
8080
return !(
81-
Object.values(workflows)
81+
Object.values(workflows || {})
8282
.map((workflow) => workflow.name)
8383
.includes(name || '') && name !== props.workflow?.name
8484
);

‎public/pages/workflow_detail/tools/resources/resource_list_with_flyout.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export function ResourceListWithFlyout(props: ResourceListFlyoutProps) {
7171
props.workflow.resourcesCreated.forEach((resource) => {
7272
resourcesMap[resource.id] = resource;
7373
});
74-
setAllResources(Object.values(resourcesMap));
74+
setAllResources(Object.values(resourcesMap || {}));
7575
}
7676
}, [props.workflow?.resourcesCreated]);
7777

‎public/pages/workflow_detail/workflow_inputs/ingest_inputs/advanced_settings.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export function AdvancedSettings(props: AdvancedSettingsProps) {
3737
const { values, setFieldValue } = useFormikContext<WorkflowFormValues>();
3838
const { models, connectors } = useSelector((state: AppState) => state.ml);
3939
const ingestMLProcessors = (Object.values(
40-
values?.ingest?.enrich
40+
values?.ingest?.enrich || {}
4141
) as any[]).filter((ingestProcessor) => ingestProcessor?.model !== undefined);
4242
const ingestProcessorModelIds = ingestMLProcessors
4343
.map((ingestProcessor) => ingestProcessor?.model?.id as string | undefined)
@@ -52,7 +52,7 @@ export function AdvancedSettings(props: AdvancedSettingsProps) {
5252
useEffect(() => {
5353
if (ingestProcessorModelIds.length > 0) {
5454
ingestProcessorModelIds.forEach((ingestProcessorModelId) => {
55-
const processorModel = Object.values(models).find(
55+
const processorModel = Object.values(models || {}).find(
5656
(model) => model.id === ingestProcessorModelId
5757
);
5858
if (processorModel?.connectorId !== undefined) {
@@ -91,7 +91,7 @@ export function AdvancedSettings(props: AdvancedSettingsProps) {
9191
useEffect(() => {
9292
if (ingestMLProcessors.length > 0) {
9393
ingestMLProcessors.forEach((ingestMLProcessor) => {
94-
const processorModel = Object.values(models).find(
94+
const processorModel = Object.values(models || {}).find(
9595
(model) => model.id === ingestMLProcessor?.model?.id
9696
);
9797
if (processorModel?.connectorId !== undefined) {

‎public/pages/workflow_detail/workflow_inputs/ingest_inputs/source_data_modal.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ export function SourceDataModal(props: SourceDataProps) {
266266
<EuiCompressedComboBox
267267
placeholder="Select an index"
268268
singleSelection={{ asPlainText: true }}
269-
options={Object.values(indices).map((option) => {
269+
options={Object.values(indices || {}).map((option) => {
270270
return { label: option.name };
271271
})}
272272
onChange={(options) => {

‎public/pages/workflow_detail/workflow_inputs/search_inputs/configure_search_request.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export function ConfigureSearchRequest(props: ConfigureSearchRequestProps) {
7575
/>
7676
) : (
7777
<EuiCompressedSuperSelect
78-
options={Object.values(indices).map(
78+
options={Object.values(indices || {}).map(
7979
(option) =>
8080
({
8181
value: option.name,

‎public/pages/workflows/import_workflow/import_workflow_modal.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export function ImportWorkflowModal(props: ImportWorkflowModalProps) {
7676
workflowNameExists
7777
);
7878
}
79-
const workflowNameExists = Object.values(workflows)
79+
const workflowNameExists = Object.values(workflows || {})
8080
.map((workflow) => workflow.name)
8181
.includes(workflowName);
8282

‎public/pages/workflows/new_workflow/quick_configure_inputs.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export function QuickConfigureInputs(props: QuickConfigureInputsProps) {
5757
useEffect(() => {
5858
if (models) {
5959
setDeployedModels(
60-
Object.values(models).filter(
60+
Object.values(models || {}).filter(
6161
(model) => model.state === MODEL_STATE.DEPLOYED
6262
)
6363
);

‎public/pages/workflows/new_workflow/quick_configure_modal.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export function QuickConfigureModal(props: QuickConfigureModalProps) {
8787
const [workflowNameTouched, setWorkflowNameTouched] = useState<boolean>(
8888
false
8989
);
90-
const workflowNameExists = Object.values(workflows)
90+
const workflowNameExists = Object.values(workflows || {})
9191
.map((workflow) => workflow.name)
9292
.includes(workflowName);
9393

‎public/pages/workflows/workflow_list/resource_list.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export function ResourceList(props: ResourceListProps) {
7373
props.workflow.resourcesCreated.forEach((resource) => {
7474
resourcesMap[resource.id] = resource;
7575
});
76-
setAllResources(Object.values(resourcesMap));
76+
setAllResources(Object.values(resourcesMap || {}));
7777
}
7878
}, [props.workflow?.resourcesCreated]);
7979

‎public/utils/config_to_schema_utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ function indexConfigToSchema(
7777
'name',
7878
'This index name is already in use. Use a different name',
7979
(name) => {
80-
return !Object.values(indices)
80+
return !Object.values(indices || {})
8181
.map((index) => index.name)
8282
.includes(name || '');
8383
}

0 commit comments

Comments
 (0)
Please sign in to comment.