Skip to content

Commit

Permalink
fix: update resource viewer to handle null fields (#269)
Browse files Browse the repository at this point in the history
This change fixes an issue where the Resource Viewer Dialog crashes when the object to be displayed contains a field set to null.
  • Loading branch information
ChristopherFry committed May 28, 2023
1 parent 088c268 commit a02d941
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ const useStyles = makeStyles({

const normalizeMetadata = (metadata: Metadata): void => {
Object.keys(metadata).forEach(key => {
if (metadata[key] === undefined || metadata[key] === '') {
if (
metadata[key] === undefined ||
metadata[key] === null ||
metadata[key] === ''
) {
delete metadata[key];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ const populateMetadata = (
): void => {
const STANDARD_K8S_FIELDS = ['apiVersion', 'kind', 'metadata'];

const firstLevelFields = Object.keys(object).filter(
const firstLevelFields = Object.keys(object || {}).filter(
key => !STANDARD_K8S_FIELDS.includes(key) || depth !== 1,
);

Expand Down

0 comments on commit a02d941

Please sign in to comment.