Skip to content

Commit 3ed2a88

Browse files
committed
if there are no expression elements, write the variable as null to prevent variable not found errors
1 parent bd5a496 commit 3ed2a88

File tree

1 file changed

+19
-17
lines changed

1 file changed

+19
-17
lines changed

src/main/java/edu/ucsb/nceas/mdqengine/processor/JSONDialect.java

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -82,25 +82,27 @@ public Result runCheck(Check check) {
8282
if (check.getSelector() != null) {
8383
for (Selector selector : check.getSelector()) {
8484
Expression expression = selector.getExpression();
85-
if (expression == null) {
86-
continue;
87-
}
88-
String syntax = expression.getSyntax();
89-
// NB: we don't have to worry about sub-selectors here because our jq
90-
// expressions instead just chain together within a single selector element
91-
if ("json-path".equals(syntax)) {
92-
String jq = expression.getValue();
93-
Object value;
94-
try {
95-
value = this.selectJsonPath(jq, rootNode);
96-
} catch (JsonQueryException e) {
97-
log.error("Error running check" + check.getId() + e.getMessage());
98-
result.setStatus(Status.ERROR);
99-
result.setOutput(new Output(e.getMessage()));
100-
return result;
85+
if (expression != null) {
86+
String syntax = expression.getSyntax();
87+
// NB: we don't have to worry about sub-selectors here because our jq
88+
// expressions instead just chain together within a single selector element
89+
if ("json-path".equals(syntax)) {
90+
String jq = expression.getValue();
91+
Object value;
92+
try {
93+
value = this.selectJsonPath(jq, rootNode);
94+
} catch (JsonQueryException e) {
95+
log.error("Error running check" + check.getId() + e.getMessage());
96+
result.setStatus(Status.ERROR);
97+
result.setOutput(new Output(e.getMessage()));
98+
return result;
99+
}
100+
variables.put(selector.getName(), value);
101101
}
102-
variables.put(selector.getName(), value);
102+
} else {
103+
variables.put(selector.getName(), null);
103104
}
105+
104106
}
105107
}
106108

0 commit comments

Comments
 (0)