Skip to content

Commit 4828d59

Browse files
committed
fixed #243 - missing flow causes error
1 parent 1e10ea4 commit 4828d59

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

marklogic-data-hub/src/main/resources/ml-modules/root/com.marklogic.hub/lib/flow-lib.xqy

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ declare %private function flow:get-writer(
218218
declare function flow:get-flow(
219219
$entity-name as xs:string,
220220
$flow-name as xs:string,
221-
$flow-type as xs:string?) as element(hub:flow)
221+
$flow-type as xs:string?) as element(hub:flow)?
222222
{
223223
let $uris :=
224224
hul:run-in-modules(function() {
@@ -228,6 +228,7 @@ declare function flow:get-flow(
228228
return
229229
cts:uri-match($ENTITIES-DIR || $entity-name || "/" || $type || "/" || $flow-name || "/*")
230230
})
231+
where fn:count($uris) > 0
231232
return
232233
flow:get-flow($entity-name, $flow-name, $flow-type, $uris)
233234
};
@@ -573,7 +574,7 @@ declare function flow:run-plugin(
573574
$simple as xs:boolean,
574575
$options as map:map)
575576
{
576-
let $module-uri as xs:string := $plugin/@module
577+
let $module-uri as xs:string? := $plugin/@module
577578
return
578579
if (fn:empty($module-uri)) then ()
579580
else

marklogic-data-hub/src/main/resources/ml-modules/root/com.marklogic.hub/mlcp-flow-transform.xqy

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ declare function mlcpFlow:transform(
3232
map:get($paramMap, 'flow-name'),
3333
map:get($paramMap, 'flow-type'))
3434

35+
let $_ :=
36+
if ($flow) then ()
37+
else
38+
fn:error(xs:QName("MISSING_FLOW"), "The specified flow " || map:get($paramMap, "flow-name") || " is missing.")
39+
3540
let $envelope := try {
3641
flow:run-plugins($flow, $uri, map:get($content, "value"), $paramMap)
3742
}

0 commit comments

Comments
 (0)