fix: data scope report error with invalid variables (#2811)

* fix: data scope error with invalidate variables

* fix: data scope error with invalidate variables
This commit is contained in:
katherinehhh 2023-10-12 13:34:17 +08:00 committed by GitHub
parent 9311b4730a
commit 49f4d1828d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 3 deletions

View File

@ -32,7 +32,7 @@ export const filterAnalyses = (filters): any[] => {
return true;
}
const regex = /\{\{\$(?:[a-zA-Z_]\w*)\.([a-zA-Z_]\w*)(?:\.id)?\}\}/;
const fieldName = jsonlogic?.value.match(regex)?.[1];
const fieldName = jsonlogic?.value.match?.(regex)?.[1];
if (fieldName) {
results.push(fieldName);
}

View File

@ -71,7 +71,7 @@ const VariablesProvider = ({ children }) => {
);
if (Array.isArray(current)) {
const result = current.map((item) => {
if (shouldToRequest(item[key]) && item.id != null) {
if (shouldToRequest(item?.[key]) && item?.id != null) {
if (associationField?.target) {
const url = `/${collectionName}/${item.id}/${key}:${getAction(associationField.type)}`;
if (hasRequested(url)) {
@ -90,7 +90,7 @@ const VariablesProvider = ({ children }) => {
return result;
}
}
return item[key];
return item?.[key];
});
current = _.flatten(await Promise.all(result));
} else if (shouldToRequest(current[key]) && current.id != null && associationField?.target) {