#Serverless not returning error

10 messages · Page 1 of 1 (latest)

rose walrus
#

The following code:

def handler(event):
    try:
        logger.info('validating input')
        validated_input = validate(event['input'], INPUT_SCHEMA)
        text = "Here is my input: {}".format(validated_input)
        logger.info(text)
        if 'errors' in validated_input:
            return {
                'error': validated_input['errors']
            }
        logger.info('running inferance')
        data = inferance_api(validated_input['validated_input'])

is returning the following logs:


Failed to return job results. | 400, message='Bad Request', url=URL('https://api.runpod.ai/v2/66w85qdd7bcp4t/job-done/8i26p55unhx4my/6843025a-7bbb-48ad-9da3-1b7b569c8d84-e1?gpu=NVIDIA+RTX+A5000&isStream=false')
barren ridgeBOT
#

To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution

pastel cradle
#

The error key can only accept str and not a list or dict.

#

Correct way of handling errors and causing the job to fail:
If the error is a string:

return {
    "error": f"An error occurred while processing the job: {e}"
}

If its a list or dict:

return {
    "error": f"Some error message",
    "output": someDict | someList
}
#

You can also do something like this:

return {
            'error': '\n'.join(validated_input['errors'])
        }
#

But the way you're doing it is incorrect.

#

@cinder maple can't this be fixed in SDK? More and more people are having this issue, including me.

cinder maple
#

I'll take a look, I thought I was just converting any error into a string as of now.

pastel cradle
#

Oh maybe it does, I haven't checked out the latest SDK version, but it was an issue for me.

rose walrus
#

your fix worked @pastel cradle thank you! not sure why my docker file bundled an old runpod version - the same code runs on a different serverless endpoint