Skip to content

KeyError

Problem

I have made a request to my deployment which failed and in the logs I get the following error:

KeyError: 'number'

Solution

The problem is caused by the fact that you try to access a variable, 'number' in our case, from a dictionary where it doesn't exist. Usually, this happens if you have a mismatch between the input fields you have configured for your deployment and the keys that are being accessed in your code.

To fix the issue you have to adjust your deployment or pipeline input fields to match the variable name with which you access the data in the code. Or change your deployment's code to match the input field's name.

For example, if you have a deployment with input field "num", then your deployment file should access that input variable with value = data['num'].