According to the specification [1], the error response status code should be 422 when there is a validation error with one or more of the objects in the request [1] https://github.com/github/git-lfs/blob/master/docs/api/v1/http-v1-batch.md#response-errors Change-Id: Id03fe00a2109b896d9a154228a14a33bce5accc3 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>tags/v4.5.0.201609210915-r
getContent(id.name().substring(0, 60), f); | getContent(id.name().substring(0, 60), f); | ||||
fail("expected RuntimeException"); | fail("expected RuntimeException"); | ||||
} catch (RuntimeException e) { | } catch (RuntimeException e) { | ||||
assertEquals("Status: 400 Bad Request", | |||||
assertEquals("Status: 422 Unprocessable Entity", | |||||
e.getMessage()); | e.getMessage()); | ||||
} | } | ||||
} | } | ||||
getContent(id.name().replace('f', 'z'), f); | getContent(id.name().replace('f', 'z'), f); | ||||
fail("expected RuntimeException"); | fail("expected RuntimeException"); | ||||
} catch (RuntimeException e) { | } catch (RuntimeException e) { | ||||
assertEquals("Status: 400 Bad Request", | |||||
assertEquals("Status: 422 Unprocessable Entity", | |||||
e.getMessage()); | e.getMessage()); | ||||
} | } | ||||
} | } |
HttpServletResponse rsp) throws IOException { | HttpServletResponse rsp) throws IOException { | ||||
String info = req.getPathInfo(); | String info = req.getPathInfo(); | ||||
if (info.length() != 1 + Constants.LONG_OBJECT_ID_STRING_LENGTH) { | if (info.length() != 1 + Constants.LONG_OBJECT_ID_STRING_LENGTH) { | ||||
sendError(rsp, HttpStatus.SC_BAD_REQUEST, MessageFormat | |||||
sendError(rsp, HttpStatus.SC_UNPROCESSABLE_ENTITY, MessageFormat | |||||
.format(LfsServerText.get().invalidPathInfo, info)); | .format(LfsServerText.get().invalidPathInfo, info)); | ||||
return null; | return null; | ||||
} | } | ||||
try { | try { | ||||
return LongObjectId.fromString(info.substring(1, 65)); | return LongObjectId.fromString(info.substring(1, 65)); | ||||
} catch (InvalidLongObjectIdException e) { | } catch (InvalidLongObjectIdException e) { | ||||
sendError(rsp, HttpStatus.SC_BAD_REQUEST, e.getMessage()); | |||||
sendError(rsp, HttpStatus.SC_UNPROCESSABLE_ENTITY, e.getMessage()); | |||||
return null; | return null; | ||||
} | } | ||||
} | } |