Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

pass {} to JSON.parse if input is empty string

天舟49524aae4e36
diff --git a/frontend/src/store/modules/activity.ts b/frontend/src/store/modules/activity.ts
index fac5d0a9e8..3f13fbf2ec 100644
--- a/frontend/src/store/modules/activity.ts
+++ b/frontend/src/store/modules/activity.ts
@@ -17,7 +17,7 @@ function convert(
rootGetters: any
): Activity {
const payload = activity.attributes.payload
- ? JSON.parse(activity.attributes.payload as string) || {}
+ ? JSON.parse((activity.attributes.payload as string) || "{}")
: {};
return {
diff --git a/frontend/src/store/modules/instance.ts b/frontend/src/store/modules/instance.ts
index 79a266b2e7..b1f2f8558b 100644
--- a/frontend/src/store/modules/instance.ts
+++ b/frontend/src/store/modules/instance.ts
@@ -66,7 +66,7 @@ function convertUser(
function convertMigrationHistory(history: ResourceObject): MigrationHistory {
const payload = history.attributes.payload
- ? JSON.parse(history.attributes.payload as string) || {}
+ ? JSON.parse((history.attributes.payload as string) || "{}")
: {};
return {
...(history.attributes as Omit<
diff --git a/frontend/src/store/modules/task.ts b/frontend/src/store/modules/task.ts
index a135151da8..2e6aa7d4e0 100644
--- a/frontend/src/store/modules/task.ts
+++ b/frontend/src/store/modules/task.ts
@@ -28,7 +28,7 @@ function convertTaskRun(
rootGetters: any
): TaskRun {
const payload = taskRun.attributes.payload
- ? JSON.parse(taskRun.attributes.payload as string) || {}
+ ? JSON.parse((taskRun.attributes.payload as string) || "{}")
: {};
return {
@@ -44,11 +44,11 @@ function convertTaskCheckRun(
rootGetters: any
): TaskCheckRun {
const result = taskCheckRun.attributes.result
- ? JSON.parse(taskCheckRun.attributes.result as string) || {}
+ ? JSON.parse((taskCheckRun.attributes.result as string) || "{}")
: {};
const payload = taskCheckRun.attributes.payload
- ? JSON.parse(taskCheckRun.attributes.payload as string) || {}
+ ? JSON.parse((taskCheckRun.attributes.payload as string) || "{}")
: {};
return {
@@ -70,7 +70,7 @@ function convertPartial(
const creator = task.attributes.creator as Principal;
const updater = task.attributes.updater as Principal;
const payload = task.attributes.payload
- ? JSON.parse(task.attributes.payload as string) || {}
+ ? JSON.parse((task.attributes.payload as string) || "{}")
: {};
const taskRunList: TaskRun[] = [];
diff --git a/frontend/src/store/modules/uistate.ts b/frontend/src/store/modules/uistate.ts
index 9182a5094a..1fd2d8ba47 100644
--- a/frontend/src/store/modules/uistate.ts
+++ b/frontend/src/store/modules/uistate.ts
@@ -35,7 +35,7 @@ const saveStateByKey = function (
state: boolean
): boolean {
const item = localStorage.getItem(module);
- const fullState = item ? JSON.parse(item) || {} : {};
+ const fullState = item ? JSON.parse(item) : {};
fullState[key] = state;
localStorage.setItem(module, JSON.stringify(fullState));
return fullState[key];
@@ -59,14 +59,12 @@ const actions = {
async restoreState({ commit }: any) {
const storedCollapseState = localStorage.getItem(COLLAPSE_MODULE);
const collapseState = storedCollapseState
- ? JSON.parse(storedCollapseState) || {}
+ ? JSON.parse(storedCollapseState)
: {};
commit("setCollapseState", collapseState);
const storedIntroState = localStorage.getItem(INTRO_MODULE);
- const introState = storedIntroState
- ? JSON.parse(storedIntroState) || {}
- : {};
+ const introState = storedIntroState ? JSON.parse(storedIntroState) : {};
commit("setIntroState", introState);
},