-
Notifications
You must be signed in to change notification settings - Fork 17
OCPBUGS-78542: fix useHistory crash and null safety guards #178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -186,7 +186,7 @@ export const transformDataToTopologyModel = ( | |
|
|
||
| const childNodes = createNodes( | ||
| nnsName, | ||
| [...nodeState.status.currentState.interfaces, ...creatingPolicyToAdd], | ||
| [...(nodeState.status?.currentState?.interfaces || []), ...creatingPolicyToAdd], | ||
| nnceConfigredInterfaces, | ||
| ); | ||
|
|
||
|
|
@@ -221,8 +221,8 @@ const getCorrelatedEnactment = ( | |
| availableEnhancments: V1beta1NodeNetworkConfigurationEnactment[], | ||
| nnsName: string, | ||
| ): V1beta1NodeNetworkConfigurationEnactment => { | ||
| return availableEnhancments.find((nnce) => | ||
| nnce.metadata.ownerReferences.some((ref) => ref.name === nnsName), | ||
| return availableEnhancments?.find((nnce) => | ||
| nnce.metadata?.ownerReferences?.some((ref) => ref.name === nnsName), | ||
|
Comment on lines
+224
to
+225
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo "== Function signature and return expression =="
rg -n -C2 'const getCorrelatedEnactment|availableEnhancments\?\.\s*find|V1beta1NodeNetworkConfigurationEnactment' src/views/nodenetworkconfiguration/utils/utils.ts
echo
echo "== TypeScript strictness flags in tsconfig files =="
fd 'tsconfig.*json' -t f | while read -r f; do
echo "-- $f --"
rg -n '"strict"\s*:|"strictNullChecks"\s*:' "$f" || true
doneRepository: openshift/nmstate-console-plugin Length of output: 1204 🏁 Script executed: # Search for all usages of getCorrelatedEnactment
rg -n 'getCorrelatedEnactment' src/views/nodenetworkconfiguration/utils/utils.ts
# Also check if it's exported and used elsewhere
rg -r 'getCorrelatedEnactment' src/ --type ts --type tsxRepository: openshift/nmstate-console-plugin Length of output: 239 🏁 Script executed: # Get context around the function call at line 179 to see how the result is used
rg -n -A 10 -B 5 'const enhancment = getCorrelatedEnactment' src/views/nodenetworkconfiguration/utils/utils.tsRepository: openshift/nmstate-console-plugin Length of output: 702 🏁 Script executed: # Get the full implementation of getNNCEConfiguredInterfaces
rg -n -A 20 'const getNNCEConfiguredInterfaces' src/views/nodenetworkconfiguration/utils/utils.tsRepository: openshift/nmstate-console-plugin Length of output: 793 Type contract no longer matches actual return value.
Proposed fixconst getCorrelatedEnactment = (
- availableEnhancments: V1beta1NodeNetworkConfigurationEnactment[],
+ availableEnhancments: V1beta1NodeNetworkConfigurationEnactment[] | undefined,
nnsName: string,
-): V1beta1NodeNetworkConfigurationEnactment => {
+): V1beta1NodeNetworkConfigurationEnactment | undefined => {
return availableEnhancments?.find((nnce) =>
nnce.metadata?.ownerReferences?.some((ref) => ref.name === nnsName),
);
};🤖 Prompt for AI Agents |
||
| ); | ||
| }; | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Return a concrete default status instead of allowing
undefinedLine 4 can now evaluate to
undefined, butgetEnactmentStatusis typed asstringand callers use the result as a status key/value. This can silently createundefinedentries and break filtering/state grouping behavior downstream.Suggested fix
📝 Committable suggestion
🤖 Prompt for AI Agents