Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bad json should be 400 not 500 #944

Merged
merged 3 commits into from
Oct 11, 2019

Conversation

ryandawsonuk
Copy link
Contributor

fixes #943

@ryandawsonuk ryandawsonuk changed the title bad json should be 400 bad json should be 400 not 500 Oct 11, 2019
@adriangonz
Copy link
Contributor

It makes sense to return a 400 if the JSON request is incorrect, but should we also return a 400 in this case?

try
{
SeldonMessage response = predictionService.predict(request);
String responseJson = ProtoBufUtils.toJson(response);
return new ResponseEntity<String>(responseJson,HttpStatus.OK);
}
catch (InterruptedException e) {
throw new APIException(ApiExceptionType.ENGINE_INTERRUPTED,e.getMessage());
} catch (ExecutionException e) {
if (e.getCause().getClass() == APIException.class){
throw (APIException) e.getCause();
}
else
{
throw new APIException(ApiExceptionType.ENGINE_EXECUTION_FAILURE,e.getMessage());
}
} catch (InvalidProtocolBufferException e) {
throw new APIException(ApiExceptionType.ENGINE_INVALID_JSON,"");
}

I'm assuming that in that case, the downstream predictive service returned a invalid JSON. It's not clear to me if that should be considered a server or client error.

PS: I'm aware this is a bit nitpicky.

@ukclivecox
Copy link
Contributor

It makes sense to return a 400 if the JSON request is incorrect, but should we also return a 400 in this case?

try
{
SeldonMessage response = predictionService.predict(request);
String responseJson = ProtoBufUtils.toJson(response);
return new ResponseEntity<String>(responseJson,HttpStatus.OK);
}
catch (InterruptedException e) {
throw new APIException(ApiExceptionType.ENGINE_INTERRUPTED,e.getMessage());
} catch (ExecutionException e) {
if (e.getCause().getClass() == APIException.class){
throw (APIException) e.getCause();
}
else
{
throw new APIException(ApiExceptionType.ENGINE_EXECUTION_FAILURE,e.getMessage());
}
} catch (InvalidProtocolBufferException e) {
throw new APIException(ApiExceptionType.ENGINE_INVALID_JSON,"");
}

I'm assuming that in that case, the downstream predictive service returned a invalid JSON. It's not clear to me if that should be considered a server or client error.

PS: I'm aware this is a bit nitpicky.

I suppose its a 500 as the bad JSON is coming from the model rather than the client?

@ryandawsonuk
Copy link
Contributor Author

Yeah I guess bad request and bad response should actually be separated as different cases

@ryandawsonuk
Copy link
Contributor Author

Have updated now

@adriangonz
Copy link
Contributor

/approve

@ryandawsonuk
Copy link
Contributor Author

/approve

@seldondev
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: adriangonz, ryandawsonuk

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@seldondev seldondev merged commit 00360bd into SeldonIO:master Oct 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

invalid json should not be a 500
4 participants