Merge pull request #25874 from stephenglass/fix/review-json-object

fix: Add null check for review state utility function
This commit is contained in:
Ben Lambert
2024-08-01 11:10:17 +02:00
committed by GitHub
3 changed files with 12 additions and 3 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-scaffolder-react': patch
---
Fix null check in `isJsonObject` utility function for scaffolder review state component
@@ -1,5 +1,5 @@
/*
* Copyright 2022 The Backstage Authors
* Copyright 2024 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,6 +33,10 @@ describe('isJsonObject', () => {
expect(isJsonObject(true)).toBe(false);
expect(isJsonObject(undefined)).toBe(false);
});
it('should return false for null values', () => {
expect(isJsonObject(null)).toBe(false);
});
});
describe('getLastKey', () => {
@@ -1,5 +1,5 @@
/*
* Copyright 2022 The Backstage Authors
* Copyright 2024 The Backstage Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -17,7 +17,7 @@
import { JsonObject, JsonValue } from '@backstage/types';
export function isJsonObject(value?: JsonValue): value is JsonObject {
return typeof value === 'object' && !Array.isArray(value);
return typeof value === 'object' && value !== null && !Array.isArray(value);
}
// Helper function to get the last part of the key