R
RunPod•10mo ago
andypotato

Returning error, but request has status "Completed"

Hello, I'm using validate() from rp_validator to validate my input data against a schema. The relevant line of code to trigger the error is:
validated_input = validate(input, INPUT_SCHEMA)
if "errors" in validated_input:
return {"error": "validated_input["errors"]}
validated_input = validate(input, INPUT_SCHEMA)
if "errors" in validated_input:
return {"error": "validated_input["errors"]}
The validation works as expected when using a local test_input.json file. It will pass when all parameters are available, it will result in the job being marked as "Failed" when parameters are missing. However when running on a serverless instance, the request will be marked as completed, despite the input validation returning an error. The log shows:
2024-02-22T08:11:23.867285503Z {"requestId": "sync-c03c0f59-b8d1-43e2-a0c9-c33466d24cd1-e1", "message": "Started.", "level": "INFO"}
2024-02-22T08:11:23.935203369Z {"requestId": "sync-c03c0f59-b8d1-43e2-a0c9-c33466d24cd1-e1", "message": "Failed to return job results. | 400, message='Bad Request', url=URL('https://api.runpod.ai/v2/1hl4lm8ob7fkf6/job-done/phuu0up50t2bqb/sync-c03c0f59-b8d1-43e2-a0c9-c33466d24cd1-e1?gpu=NVIDIA+RTX+A4500&isStream=false')", "level": "ERROR"}
2024-02-22T08:11:23.935242370Z {"requestId": "sync-c03c0f59-b8d1-43e2-a0c9-c33466d24cd1-e1", "message": "Finished.", "level": "INFO"
2024-02-22T08:11:23.867285503Z {"requestId": "sync-c03c0f59-b8d1-43e2-a0c9-c33466d24cd1-e1", "message": "Started.", "level": "INFO"}
2024-02-22T08:11:23.935203369Z {"requestId": "sync-c03c0f59-b8d1-43e2-a0c9-c33466d24cd1-e1", "message": "Failed to return job results. | 400, message='Bad Request', url=URL('https://api.runpod.ai/v2/1hl4lm8ob7fkf6/job-done/phuu0up50t2bqb/sync-c03c0f59-b8d1-43e2-a0c9-c33466d24cd1-e1?gpu=NVIDIA+RTX+A4500&isStream=false')", "level": "ERROR"}
2024-02-22T08:11:23.935242370Z {"requestId": "sync-c03c0f59-b8d1-43e2-a0c9-c33466d24cd1-e1", "message": "Finished.", "level": "INFO"
This is the response:
{
"delayTime": 1026,
"executionTime": 169,
"id": "sync-c03c0f59-b8d1-43e2-a0c9-c33466d24cd1-e1",
"status": "COMPLETED"
}
{
"delayTime": 1026,
"executionTime": 169,
"id": "sync-c03c0f59-b8d1-43e2-a0c9-c33466d24cd1-e1",
"status": "COMPLETED"
}
Why is this COMPLETED and not FAILED? Thank you for any hints or pointers.
2 Replies
ashleyk
ashleyk•10mo ago
This is because the RunPod SDK had a change made to it where it can't accept a dict or list for the error key, it only accepts an str. You now have to do something like this:
if "errors" in validated_input:
return {
"error": "Validation failed",
"output": "validated_input["errors"]
}
if "errors" in validated_input:
return {
"error": "Validation failed",
"output": "validated_input["errors"]
}
Or alternatively:
if 'errors' in validated_input:
return {
'error': '\n'.join(validated_input['errors'])
}
if 'errors' in validated_input:
return {
'error': '\n'.join(validated_input['errors'])
}
andypotato
andypotatoOP•10mo ago
Thank you Askley, it's working now 🙂
Want results from more Discord servers?
Add your server