1 Resposta
- Mais recentes
- Mais votos
- Mais comentários
1
It looks like the error you're encountering is a KeyError
, which means the key you're trying to access in the dictionary doesn't exist. Based on the error message, it seems that PROC
is missing from the dictionary output. This could happen if the dictionary doesn't contain the key PROC
for some reason.
To troubleshoot, you can add some additional logging to check the keys present in the output dictionary before trying to access them. For example:
output = json.loads(dump_info) print(output) jdata_type = type(output) print(jdata_type) # Check if the keys exist in the dictionary if 'AWSDT' in output: BATCHTIME = output['AWSDT'] else: logger.error('Key AWSDT not found in dictionary') if 'DATALOADCONFIGID' in output: CONFIGID = output['DATALOADCONFIGID'] else: logger.error('Key DATALOADCONFIGID not found in dictionary') if 'PROC' in output: PROCNAME = output['PROC'] else: logger.error('Key PROC not found in dictionary') if 'TABLENAME' in output: TABLENAME = output['TABLENAME'] else: logger.error('Key TABLENAME not found in dictionary') if 'FILENAME' in output: KEYNAME = output['FILENAME'] else: logger.error('Key FILENAME not found in dictionary') logger.info('Variables loaded') logger.info('Values used {},{},{},{},{},'.format(PROCNAME, CONFIGID, TABLENAME, KEYNAME, BATCHTIME))
Conteúdo relevante
- AWS OFICIALAtualizada há 2 anos
- AWS OFICIALAtualizada há 2 meses
- AWS OFICIALAtualizada há 3 meses
Osvaldo - thankyou for offering a answer but I am trying to understand if there is a way that my Keys have to be surfaced using a Step Function than when I execute as a standalone Lambda function. The payload shown in the Step Function GUI shows that the Keys are being passed and when I print the EVENT data they are shown as well.
"Payload": { "AWSDT": "2024-03-07 06:21:00", "DATALOADCONFIGID": 1, "PROC": "Info.usp_Load_F7", "TABLENAME": "Info.F7", "FILENAME": "F7_202403070621.csv" }
It's possible that the 'PROC' key is not being correctly passed from the Step Function to the Lambda function. Despite appearing in the Step Function GUI and your print statements, there might be an issue with how it's extracted or processed in your Lambda function. Check for typos, confirm the 'output' dictionary's contents, and ensure it's not modified before accessing 'PROC'. Simplify your code, verify the Step Function's output, and review how data is passed to the Lambda function.