Skip to content

Commit

Permalink
Resolving 500 error issue from invalid list params to return 400
Browse files Browse the repository at this point in the history
instead.

RB=710953
G=si-dev
A=xma
  • Loading branch information
Kenta Labur committed Apr 26, 2016
1 parent 0ace10a commit c054859
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG
@@ -1,3 +1,6 @@
6.0.3
------

6.0.2
------
(RB=710508)
Expand All @@ -9,6 +12,9 @@ Added cookies to isEquals/hashCode/toString in Request.java
(RB=705680)
Added addAcceptTypes and addAcceptType to RestliRequestOptionsBuilder

(RB=710953)
Resolving 500 error issue from invalid list params to return 400 instead.

6.0.1
------
Bump zookeeper library from 3.3.4 to 3.4.6
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
@@ -1,4 +1,4 @@
version=6.0.1
version=6.0.2
sonatypeUsername=please_set_in_home_dir_if_uploading_to_maven_central
sonatypePassword=please_set_in_home_dir_if_uploading_to_maven_central

Expand Down
Expand Up @@ -605,9 +605,20 @@ else if (context.hasParameter(RestConstants.QUERY_BATCH_IDS_PARAM))
{
Key key = resource.getPrimaryKey();
Object value;
// in v2, compound keys have already been converted and dealt with, so all we need to do here is convert simple values.
value = ArgumentUtils.convertSimpleValue(id, key.getDataSchema(), key.getType());
batchKeys.add(value);
try
{
// in v2, compound keys have already been converted and dealt with, so all we need to do here is convert simple values.
value = ArgumentUtils.convertSimpleValue(id, key.getDataSchema(), key.getType());
batchKeys.add(value);
}
catch (NumberFormatException e)
{
throw new RoutingException("NumberFormatException parsing batch key '" + id + "'", HttpStatus.S_400_BAD_REQUEST.getCode(), e);
}
catch (IllegalArgumentException e)
{
throw new RoutingException("IllegalArgumentException parsing batch key '" + id + "'", HttpStatus.S_400_BAD_REQUEST.getCode(), e);
}
}
}
else
Expand Down
Expand Up @@ -2495,6 +2495,18 @@ public Object[][] invalidList()
"DELETE",
"CREATE"
},
{
"/statuses?ids=List(NONE)",
AllProtocolVersions.RESTLI_PROTOCOL_2_0_0.getProtocolVersion(),
"DELETE",
"CREATE"
},
{
"/statuses?ids=List(1,2,3,NONE)",
AllProtocolVersions.RESTLI_PROTOCOL_2_0_0.getProtocolVersion(),
"DELETE",
"CREATE"
},
};
}

Expand Down

0 comments on commit c054859

Please sign in to comment.