【问题标题】:Invalid type for parameter input (step_function.start_execution)参数输入的类型无效(step_function.start_execution)
【发布时间】:2021-11-19 13:15:26
【问题描述】:

我有一个 start_execution 命令来通过我的 lambda 函数 (python) 启动一个步进函数:

    if event['Records'][0]['eventName'] == 'INSERT':
            filename, source, destination_bucket_name, filekey = parse_file_info_from_trigger(event)
            response = client.start_execution(
                stateMachineArn='aws:states:.......',
                input = "{\"first_name\" : \"test\"}"       
            )
    else: 
        logger.info(f'This is not an Insert event')

如何将上述提取的变量(文件名、源等)传递到 start-execution 命令的输入中?

我试过了:

 response = step_function.start_execution(
                    stateMachineArn=state_machine_zip_files_arn,
                    input = str({ "filename": f"{filename}",  "filetype": f"{filetype}",  "unixtimestamp": f"{unixtimestamp}", 
                    "masterclient": f"{masterclient}", "source_bucket_name": f"{source_bucket_name}" , 
                    "destination_bucket_name": f"{destination_bucket_name}", "filekey": f"{filekey}","this is a test string": f"teststring"})     
                    )

但它给了我一个错误:

Unable to start_execution for state machine: An error occurred (InvalidExecutionInput) when calling the StartExecution operation: Invalid State Machine Execution Input: 'Unexpected character (''' (code 39)): was expecting double-quote to start field name'

【问题讨论】:

    标签: python python-3.x amazon-web-services dictionary aws-step-functions


    【解决方案1】:

    input 的预期格式是str。您应该将您的 dict 转换为 str 如下:json.dumps(your_input_data).

    【讨论】:

    • 无法启动状态机的执行:调用 StartExecution 操作时发生错误 (InvalidExecutionInput):无效的状态机执行输入:'意外字符('''(代码 39)):期待双引用开始字段名称'
    • 我已经编辑了我的答案,使用 json.dumps 来维护双引号。
    猜你喜欢
    • 1970-01-01
    • 2018-05-22
    • 2013-09-22
    • 1970-01-01
    • 1970-01-01
    • 2016-02-03
    • 2015-06-20
    • 2013-03-10
    • 1970-01-01
    相关资源
    最近更新 更多