Skip to content

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

Return empty json on parse error

天舟47bcc82b1b59
diff --git a/frontend/src/store/modules/activity.ts b/frontend/src/store/modules/activity.ts
index 2f92aa8b60..fac5d0a9e8 100644
--- a/frontend/src/store/modules/activity.ts
+++ b/frontend/src/store/modules/activity.ts
@@ -17,8 +17,8 @@ function convert(
rootGetters: any
): Activity {
const payload = activity.attributes.payload
- ? JSON.parse(activity.attributes.payload as string)
- : undefined;
+ ? JSON.parse(activity.attributes.payload as string) || {}
+ : {};
return {
...(activity.attributes as Omit<Activity, "id">),
diff --git a/frontend/src/store/modules/instance.ts b/frontend/src/store/modules/instance.ts
index d89e78500f..79a266b2e7 100644
--- a/frontend/src/store/modules/instance.ts
+++ b/frontend/src/store/modules/instance.ts
@@ -66,8 +66,8 @@ function convertUser(
function convertMigrationHistory(history: ResourceObject): MigrationHistory {
const payload = history.attributes.payload
- ? JSON.parse(history.attributes.payload as string)
- : undefined;
+ ? JSON.parse(history.attributes.payload as string) || {}
+ : {};
return {
...(history.attributes as Omit<
MigrationHistory,
diff --git a/frontend/src/store/modules/task.ts b/frontend/src/store/modules/task.ts
index 78adb4ad37..80f8bd45f5 100644
--- a/frontend/src/store/modules/task.ts
+++ b/frontend/src/store/modules/task.ts
@@ -27,8 +27,8 @@ function convertTaskRun(
rootGetters: any
): TaskRun {
const payload = taskRun.attributes.payload
- ? JSON.parse(taskRun.attributes.payload as string)
- : undefined;
+ ? JSON.parse(taskRun.attributes.payload as string) || {}
+ : {};
return {
...(taskRun.attributes as Omit<TaskRun, "id" | "payload">),
@@ -43,12 +43,12 @@ function convertTaskCheckRun(
rootGetters: any
): TaskCheckRun {
const result = taskCheckRun.attributes.result
- ? JSON.parse(taskCheckRun.attributes.result as string)
- : undefined;
+ ? JSON.parse(taskCheckRun.attributes.result as string) || {}
+ : {};
const payload = taskCheckRun.attributes.payload
- ? JSON.parse(taskCheckRun.attributes.payload as string)
- : undefined;
+ ? JSON.parse(taskCheckRun.attributes.payload as string) || {}
+ : {};
return {
...(taskCheckRun.attributes as Omit<
@@ -69,8 +69,8 @@ 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)
- : undefined;
+ ? JSON.parse(task.attributes.payload as string) || {}
+ : {};
const taskRunList: TaskRun[] = [];
const taskRunIdList = task.relationships!.taskRun
diff --git a/frontend/src/store/modules/uistate.ts b/frontend/src/store/modules/uistate.ts
index 9caf86dd78..9182a5094a 100644
--- a/frontend/src/store/modules/uistate.ts
+++ b/frontend/src/store/modules/uistate.ts
@@ -24,7 +24,7 @@ const stateByKey = function (
}
const localStorageState = localStorage.getItem(module);
if (localStorageState) {
- return JSON.parse(localStorageState)[key];
+ return JSON.parse(localStorageState)[key] || false;
}
return false;
};
@@ -35,37 +35,39 @@ 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];
};
const getters = {
- collapseStateByKey: (state: UIState) => (key: string): boolean => {
- return stateByKey(state.collapseStateByKey, COLLAPSE_MODULE, key);
- },
-
- introStateByKey: (state: UIState) => (key: string): boolean => {
- return stateByKey(state.introStateByKey, INTRO_MODULE, key);
- },
+ collapseStateByKey:
+ (state: UIState) =>
+ (key: string): boolean => {
+ return stateByKey(state.collapseStateByKey, COLLAPSE_MODULE, key);
+ },
+
+ introStateByKey:
+ (state: UIState) =>
+ (key: string): boolean => {
+ return stateByKey(state.introStateByKey, INTRO_MODULE, key);
+ },
};
const actions = {
async restoreState({ commit }: any) {
const storedCollapseState = localStorage.getItem(COLLAPSE_MODULE);
const collapseState = storedCollapseState
- ? JSON.parse(storedCollapseState)
+ ? JSON.parse(storedCollapseState) || {}
: {};
- if (collapseState) {
- commit("setCollapseState", collapseState);
- }
+ commit("setCollapseState", collapseState);
const storedIntroState = localStorage.getItem(INTRO_MODULE);
- const introState = storedIntroState ? JSON.parse(storedIntroState) : {};
- if (introState) {
- commit("setIntroState", introState);
- }
+ const introState = storedIntroState
+ ? JSON.parse(storedIntroState) || {}
+ : {};
+ commit("setIntroState", introState);
},
async savecollapseStateByKey(