AWS Step Functions中JSONata正则表达式执行报错'threw an internal error during evaluation'的求助
AWS Step Functions中JSONata正则表达式执行报错'threw an internal error during evaluation'的求助
我现在遇到一个AWS Step Functions里的JSONata表达式问题,想请教大家帮忙解决。
需求背景
我有一段JSONata表达式,在JSONata v1.3.3及以上版本里运行正常,目的是移除所有以somatic开头的键。表达式如下:
$states.input ~> $sift(function($v, $k){ $k ~> /^(?!somatic)/ })
测试数据是这样的:
{ "states": { "input": { "alignmentOptions": { "enableDuplicateMarking": true }, "targetedCallerOptions": { "enableTargeted": [ "cyp2d6" ] }, "snvVariantCallerOptions": { "qcDetectContamination": true, "vcMnvEmitComponentCalls": true, "vcCombinePhasedVariantsDistance": 2, "vcCombinePhasedVariantsDistanceSnvsOnly": 2 }, "somaticCnvCallerOptions": { "enableCnv": true, "enableHrd": true, "cnvUseSomaticVcBaf": true }, "somaticSvCallerOptions": { "enableSv": true } } } }
预期返回结果是过滤掉所有带somatic前缀的键:
{ "alignmentOptions": { "enableDuplicateMarking": true }, "targetedCallerOptions": { "enableTargeted": [ "cyp2d6" ] }, "snvVariantCallerOptions": { "qcDetectContamination": true, "vcMnvEmitComponentCalls": true, "vcCombinePhasedVariantsDistance": 2, "vcCombinePhasedVariantsDistanceSnvsOnly": 2 } }
遇到的问题
我在AWS Step Functions的Pass任务里用了这段表达式,任务定义如下:
{ "Type": "Pass", "End": true, "Output": "{% $states.input ~> $sift(function($v, $k){$k ~> /^(?!somatic)/}) %}" }
结果执行时直接报错了:
{ "error": "States.QueryEvaluationError", "cause": "The JSONata expression '$states.input ~> $sift(function($v, $k){$k ~> /^(?!somatic)/})' specified for the field 'Output' threw an internal error during evaluation. 1ae1f889-d232-46cd-b6b1-1db7b0e28796" }
已知信息
我知道AWS Step Functions的JSONata和标准JSONata环境有一些差异,比如$eval对应$parse,合并操作符??不支持,但之前没遇到过正则相关的错误。我猜测可能是正则里的**负向预查?!**导致的语法兼容性问题?
有没有朋友遇到过类似情况,或者知道怎么替换这个正则来实现同样的过滤效果?
内容来源于stack exchange
相关产品推荐
相关产品推荐

