【发布时间】:2021-05-15 16:21:27
【问题描述】:
当调用负载中包含float('nan') 的状态机时,由于Non-standard token 'NaN',结果提示启用JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS。
import boto3
import json
client = boto3.client('stepfunctions', endpoint_url=endpoint_url)
client.start_sync_execution(stateMachineArn='state_machine_arn',
name='new-execution',
input=json.dumps({'foo': float('nan')})
(截断)
InvalidExecutionInput Traceback (most recent call last)
...
~/opt/miniconda3/envs/pandars38/lib/python3.8/site-packages/botocore/client.py in _make_api_call(self, operation_name, api_params)
674 error_code = parsed_response.get("Error", {}).get("Code")
675 error_class = self.exceptions.from_code(error_code)
--> 676 raise error_class(parsed_response, operation_name)
677 else:
678 return parsed_response
InvalidExecutionInput: An error occurred (InvalidExecutionInput) when calling the StartSyncExecution operation: Invalid State Machine Execution Input: 'Non-standard token 'NaN': enable JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS to allow'
(包装)
InvalidExecutionInput:
An error occurred (InvalidExecutionInput) when calling the StartSyncExecution operation:
Invalid State Machine Execution Input:
'Non-standard token 'NaN': enable JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS to allow'
同样的异常也发生在 numpy np.nan 上。
【问题讨论】:
-
嗨,不确定这是否会引起兴趣 forums.aws.amazon.com/message.jspa?messageID=761953 或者可能将类型更改为字符串以便可以包含像 NaN 这样的非标准值?
-
谢谢,是的,现在我只是将任何 NaN 更改为基本上 null ,但只是好奇是否有人知道如何访问这个神秘的
JsonParser.Feature.ALLOW_NON_NUMERIC_NUMBERS哈哈。
标签: python json python-3.x state-machine aws-step-functions